In this python dictionary program, we will add elements to the dictionary.
Steps to solve the program
- Create an empty dictionary by using {}.
- Add elements to the dictionary.
- To add elements use the following format: Dictionary_name[key_name] = value.
- Print the output.
Output :
dictionary = {}
dictionary["Name"] = "Ketan"
dictionary["Age"] = "21"
print(dictionary)
{'Name': 'Ketan', 'Age': '21'}
print the square of all values in a dictionary.