Professional Documents
Culture Documents
ENGR 101
Introduction to Programming
Week 11
eng2sp = dict()
print(eng2sp)
{}
• E.g.
one uno
two dos
...
print_dict(eng2sp)
one uno
two dos
...
vals = eng2sp.values()
print('uno' in vals)
True
d.setdefault(key, value):
if key exists in d, does not modify d.
otherwise, inserts key:value pair in d.
always returns the value associated with key.
h = histogram('parrot')
print_dict(h)
a 1
p 1
...
<class 'tuple'>
'a'