Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Write a Python program to remove a key from a dictionary.

#delete  'a' and 'b'
d = {'a':1,'b':2,'c':3,'d':4}  

if 'a' and 'b' in d:
    del d['a']
    del d['b']
    print(d)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Write #Python #program #remove #key
ADD COMMENT
Topic
Name
4+8 =