Informatics Practices
Find errors and rewrite the same after correcting the following code:
del d1(2)
Python Dictionaries
1 Like
Answer
In Python, to delete an element from a dictionary, we should use square brackets [], not parentheses ().
The corrected code is:
del d1[2]
Answered By
1 Like
Related Questions
Find errors and rewrite the same after correcting the following code:
d1 = {1:10, 2.5:20, 3:30, 4:40, 5:50, 6:60, 7:70}Find errors and rewrite the same after correcting the following code:
d1(9) = 90Find errors and rewrite the same after correcting the following code:
pop d1[4]Find errors and rewrite the same after correcting the following code:
d1.item()