daniel-s
6/29/2015 - 10:34 AM

Python dictionary.

Python dictionary.

# Iterate over keys and values of a dict
for key, value in my_dict.iteritems():
  pass

# Add elements with unexisting keys
my_dict = defaultdict(set) # Each new added element that doesn't exist will call set()
my_dict = defaultdict(list) # Each new added element that doesn't exist will call list()