2014-01-06 14:48:34 -05: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:
|
2020-03-26 22:07:33 -04:00
|
|
|
print(d.pop(1), "!!!")
|
2014-01-06 14:48:34 -05:00
|
|
|
except KeyError:
|
|
|
|
print("Raised KeyError")
|
|
|
|
else:
|
2020-03-26 22:07:33 -04:00
|
|
|
print("Did not raise KeyError!")
|