circuitpython/tests/basics/dict_setdefault.py

14 lines
191 B
Python
Raw Normal View History

2014-01-06 15:25:51 -05:00
d = {}
print(d.setdefault(1))
print(d.setdefault(1))
print(d.setdefault(5, 42))
print(d.setdefault(5, 1))
print(d[1])
print(d[5])
d.pop(5)
print(d.setdefault(5, 1))
print(d[1])
print(d[5])