Informatics Practices

Find errors and rewrite the same after correcting the following code:

d1.clears()  

Python Dictionaries

3 Likes

Answer

The correct method to clear all elements from a dictionary is clear(), not clears().

The corrected code is:

d1.clear()

Answered By

2 Likes


Related Questions