pop
is a great little function that, when used on dictionaries (given a known key) removes the item with that key from the dictionary and also returns the corre
here is a simpler implementation
class CustomDict(dict):
def pop_item(self, key):
popped = {key:self[key]} #save "snapshot" of the value of key before popping
self.pop(key)
return popped
a = CustomDict()
b = {"hello":"wassup", "lol":"meh"}
a.update(b)
print(a.pop_item("lol"))
print(a)
So here we create a custom dict
that pops the item you want and gives out the key-value pair