Source Code:
(back to article)
# Create an empty dictionary my_dict = {} # Add a new key-value pair using the update() method my_dict.update({'name': 'John'}) # Add a new key-value pair using square brackets my_dict['age'] = 30 print(my_dict) # {'name': 'John', 'age': 30}
Result:
Report an issue