Two ways to add an item to dictionary in Python

Example:

my_dictionary = {'name': 'Dmitri', 'topic': 'Python', 'fav_food': 'ice cream'}
# method 1
my_dictionary['course'] = 'Python'
print(my_dictionary)
# method 2
# If the key exist, the value is not set.
# If the key does not exist, it will be added
my_dictionary.setdefault('city', ' Chisinau')
print(my_dictionary)
Output:
{'name': 'Dmitri', 'topic': 'Python', 'fav_food': 'ice cream', 'course': 'Python'}
{'name': 'Dmitri', 'topic': 'Python', 'fav_food': 'ice cream', 'course': 'Python', 'city': ' Chisinau'}