Source Code:
(back to article)
# Creating a dictionary my_dict = {'Name': 'John', 'Age': 25, 'City': 'New York'} # Adding a new element using setdefault() my_dict.setdefault('Gender', 'Male') # Printing the updated dictionary print(my_dict)
Result:
Report an issue