Python program to clear the list values in the dictionary.

In this python dictionary program, we will clear the list values in the dictionary.

Steps to solve the program
  1. Take a dictionary in the given format as input
  2. Use for loop to iterate over values of the dictionary.
  3. Clear the list of values using clear().
  4. Print the output.
				
					D1 = {'virat':[50,30],'rohit':[40,10]} 
for key in D1:
    D1[key].clear()

print(D1)
				
			

Output :

				
					{'virat': [], 'rohit': []}
				
			

convert string values of a given dictionary, into integer/float datatypes.

update the list values in the said dictionary.

Leave a Comment