# DICTIONARY print("Test python's dictionary (lexikon):") friends = {'Anna': '070-1122334', 'Pelle': '0732255889', 'Olle': '0708877441'} # Value blandas: lista, int print('Print my dictionary:', friends) print("Print Olle's value:", friends['Olle']) print('Or use the get-method:',friends.get('Anna')) friends['Olle']=friends['Anna'] # now points to hte Anna-elementet print("Print Olle's value:", friends['Olle']) # print('Olle:', friends[1]) #Inte indexerbart # friends['Nisse'] = '0704455772' #Add a new element friends['Olle']='0739966551' # Change a value print('\nUpdated! ',friends) del friends['Anna'] # remove Anna :-( print('\npop Pelle',friends.pop('Pelle')) #pop removes and returns the value if 'Gun' in friends: print('Gun is my friend') else: friends['Gun']='0705566773' # Add Gun list_of_friends = list(friends) # ['Olle', 'Nisse', 'Gun'] print('\nMy best friends: ', list_of_friends) # animals = dict(dog=3, cat='Emil', horse=['Svante',5]) # key of typ str print(animals)