Medium
Apprentice
SpeedRun
dict
stdlib
defaults
Python: dict.pop With Defaults
+150 XP · 7 min · attempt 1
Problem
What integer is printed?
d = {'a': 1, 'b': 2, 'c': 3}
r = d.pop('b', 99) + d.pop('z', 99)
print(r)
Enter a single integer.
Starter
# pop returns the value if the key exists,
# otherwise the supplied default (no KeyError).