Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs

Dict Programs


Python program to Remove the item in dictionary


In this example shows, method shows the how to remove the items to the dictionary.

Example.py
dict = {"SamKumar": 21, "Saraa":18, "Alex": 24, "Aravind": 24}
#print the dictionery before removal
print("The dictionary before remove is : ", dict)
#delete the given key
del dict['Saraa']
#print the dictionery after removal
print("The dictionary after remove is : ", dict)

Output

The dictionary before remove is :  {'SamKumar': 21, 'Saraa': 18, 'Alex': 24, 'Aravind': 24}
The dictionary after remove is :  {'SamKumar': 21, 'Alex': 24, 'Aravind': 24}

Prev Next