Python program to clear all items from the dictionary.

In this python dictionary program, we will clear all items from the dictionary using an in-built function.

Steps to solve the program
  1. Take a dictionary as input.
  2. Clear all items from the given dictionary using clear().
  3. Print the output.
				
					dict1 = {'Name':'Harry','Rollno':345,'Address':'Jordan'}

dict1.clear()
print(dict1)
				
			

Output :

				
					{}
				
			

store squares of even and cubes of odd numbers in a dictionary using dictionary comprehension.

remove duplicate values from Dictionary.

Leave a Comment