In this python dictionary program, we will clear the list values in the dictionary.
Steps to solve the program
- Take a dictionary in the given format as input
- Use for loop to iterate over values of the dictionary.
- Clear the list of values using clear().
- Print the output.
D1 = {'virat':[50,30],'rohit':[40,10]}
for key in D1:
D1[key].clear()
print(D1)
Output :
{'virat': [], 'rohit': []}