Dictionaries come with built-in methods that allow you to perform the following tasks:
• Retrieve items from dicts by using items(), keys(), and values() methods.
• Use dicts in loops with iterkeys(), itervalues(), and iteritems() methods.
• Test whether a key is in a dict by using the in keyword.
• Delete items from dicts by using the del keyword and the popitem() and pop() methods.
• Make shallow copies of dicts by using the copy() method.
• Add items to dicts by using the setdefault() method.
Was this article helpful?