+ 3

how do we delete a key and value from a dictionary?

11th Oct 2016, 2:46 PM
ARUNKUMAR S
ARUNKUMAR S - avatar
3 odpowiedzi
+ 2
A search says: del mydict['key'] Setting it to None doesn't remove it or provide for garbage collection. http://stackoverflow.com/questions/8237647/clear-variable-in-JUMP_LINK__&&__python__&&__JUMP_LINK
11th Oct 2016, 3:13 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
use del del dict['key'] ---> will delete item which has the key 'key'
11th Oct 2016, 3:40 PM
Sunera
Sunera - avatar
0
Downvote if you like, but I'd rather the information be accurate. This is what [پسرک تک پر‬‎] appears to be doing with the non-sequitor "hacking" post. https://telegram.org/blog/bot-revolution
11th Oct 2016, 3:59 PM
Kirk Schafer
Kirk Schafer - avatar