Home »
Python »
Python Dictionary MCQs
How will you do this? Select the correct syntax to remove the element from the dictionary?
20. How will you do this? Select the correct syntax to remove the element from the dictionary.
Suppose you have the following dictionary And you want to remove the 2nd element.
dict = {1:"include helps",2:"welcomes",3:"you"}
- del dict ["2"]
- del dict=["2"]
- del dict(2)
Answer: A) del dict ["2"]
Explanation:
The del dict ["2"] will delete the second element, where 2 represents the key name.