micropython/tests/basics/dict_pop.py

13 lines
237 B
Python
Raw Normal View History

2014-01-06 19:48:34 +00:00
d = {1: 2, 3: 4}
print(d.pop(3), d)
print(d)
print(d.pop(1, 42), d)
print(d.pop(1, 42), d)
print(d.pop(1, None), d)
try:
print(d.pop(1), "!!!",)
except KeyError:
print("Raised KeyError")
else:
print("Did not rise KeyError!")