While working on Python how can i create a dictionary?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Ravi Ujjwal
Dictionary is nothing but a key value pair. It can be ordered or unordered. Handling dictionary in python is really very easy.
var = {}
var is now empty dictionary.
We can fill the dictionary like this:
var[key] = value
Ex:
var
[
0
]
=
'Tech'
var
[ 1
]
=
'Answered'
var
[ 2
]
=
1
You can also assess the dictionary like this:
var[key]
Ex:
print(var[1])
Output: Answered
References: https://www.geeksforgeeks.org/python-dictionary/