-
Use
d.popif you want to capture the removed item, like initem = d.pop("keyA"). -
Use
delif you want to delete an item from a dictionary. -
If you want to delete, suppressing an error if the key isn’t in the dictionary:
if thekey in thedict: del thedict[thekey]