What is the syntax to delete a dictionary element?

del <dictionary name>[<key>];
#examples
passwords = {'John':1123421,'Shirley':'socks', 'Galen':4234.123}
del passwords['Galen'];
print(passwords)

#output
{'John': 1123421, 'Shirley': 'socks'}

 

Advertisements