Important Notice:

Course Content
Dictionary in Python (Chapter-9) M3-R5
About Lesson

Deleting (Removing) Element from Dictionary:-

            Dictionary में से element को delete करने के लिए del keyword के साथ में square bracket([]) में unique key दी जाती है।

a={50:’Aman’, 51:’Raman’, 52:’Suman’}

print(a)                                                # {50: ‘Aman’, 51: ‘Raman’, 52: ‘Suman’}

del a[51]                                                                               

print(a)                                              # {50: ‘Aman’, 52: ‘Suman’}

 

 

Deleting (Removing) Element from Dictionary:-

            To delete an element from the dictionary, a unique key is given in square brackets ([]) along with the del keyword.

a={50:’Aman’, 51:’Raman’, 52:’Suman’}

print(a)                                            # {50: ‘Aman’, 51: ‘Raman’, 52: ‘Suman’}

del a[51]                                                                               

print(a)                                          # {50: ‘Aman’, 52: ‘Suman’}

error: Content is protected !!