In python, you have dictionary, d = {'a':1, 'b':2}, how do you delete item with key 'a' from d, and get the value of 'a' returned, all in one command (and do it in safe way so None is returned if key 'a' does not exist)?
Answer
d.pop('a', None)
Question
In python, you have dictionary, d = {'a':1, 'b':2}, how do you delete item with key 'a' from d, and get the value of 'a' returned, all in one command (and do it in safe way so None is returned if key 'a' does not exist)?
Answer
?
Question
In python, you have dictionary, d = {'a':1, 'b':2}, how do you delete item with key 'a' from d, and get the value of 'a' returned, all in one command (and do it in safe way so None is returned if key 'a' does not exist)?
Answer
d.pop('a', None)
If you want to change selection, open document below and click on "Move attachment"
pdf
owner: kkhosravi - (no access) - PYTHON_DATA_STRUCTURES_AND_ALGORITHMS.pdf, p54
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.