...
Code Block | ||
---|---|---|
| ||
kokebok = {'pasta carbonara':['fløte','pasta','bacon','egg'], 'sopp -risotto':['sopp','ris','fløte'], 'pasta bolognese':['pasta','kjøttdeig','tomatsaus']} |
...
Code Block | ||
---|---|---|
| ||
#a print(kokebok.get('pasta carbonara')) #b kokebok['kyllingsalat'] = ['kylling','tomat','agurk','salat'] #c if 'sopp -risotto' in kokebok: print ('sopp -risotto finnes i kokeboken') else: print ('beklager, opp sopp-risotto finnes ikke i kokeboken') #d del kokebok['pasta bolognese'] |
...
Code Block | ||
---|---|---|
| ||
for rett in kokebok: print (rett + ' inneholder ' + str(kokebok.get(rett))) #alternativt: for rett, innhold in kokebok.items(): s = '' for el in innhold: s += el+', ' print(rett,'inneholder',s[0:-2]) |
Oppgave 11 - Endre verdier i en dictionary
...