You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
modify a dictionary (does not return the dictionary)
family['cat'] ='snowball'# add a new entryfamily['cat'] ='snowball ii'# edit an existing entrydelfamily['cat'] # delete an entryfamily['kids'] = ['bart', 'lisa'] # value can be a listfamily.pop('dad') # removes an entry and returns the value ('homer')family.update({'baby':'maggie', 'grandpa':'abe'}) # add multiple entries
accessing values more safely with 'get'
family['mom'] # returns 'marge'family.get('mom') # same thingfamily['grandma'] # throws an errorfamily.get('grandma') # returns Nonefamily.get('grandma', 'not found') # returns 'not found' (the default)