Pop from Python Dictionary

.pop() Method in Python

We can use .pop() method to remove key-value pairs from Python dictionary. This method takes a key as an argument and removes it from the dictionary and it returns the value that it removed from the dictionary.

user = {'first_name': 'nishant', 'last_name': 'nigam', 'city': 'Indore'}


print(user) # {'first_name': 'nishant', 'last_name': 'nigam'}


Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Find duplicate records in ServiceNow