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"}
  1. del dict ["2"]
  2. del dict=["2"]
  3. del dict(2)

Answer: A) del dict ["2"]

Explanation:

The del dict ["2"] will delete the second element, where 2 represents the key name.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.