Dictionaries in Python

Share Your Love

Dictionaries in python are used to store values in a format of key:value. It is ordered and changeable but does not allow any duplicates.

Syntax Of Dictionaries in Python:

Variable name={
	Key: value
	key:value
	key:value
}

For Example Of Dictionaries In Python:

dict1={
	"Name":"lingarajtechhub"
	"UID":554412
	"RID":"A"
}

Here the values get stored as shown above and hence can be printed as:

Input:

dict={"Name":"Lingarajtechhub","UID":554412,"RID":"A"}
print(dict)

Output:

uMJEuaARqfHYBS8jr8Zu6Q78yd4hSr6Hmvvvt0UxQb4Om YI0yD zZb2KSRD73xywZTFJvqKecxevWcKcH8BfjPU LBF5p6xVTgazALXopZN d0jQXAJpbZoJOkP 2fOSoVFew

We can also print the keys of the dictionaries individually as:

Input:

dict={"Name":"Lingarajtechhub","UID":554412,"RID":"A"}
print(dict["Name"])

Output:

SeTF7FLrRMp0HAVqZYvRUtgN1nBrzW9cTkXqDlCCpw3YLLO4DNyZkQpIv9w PrEaMMizB9hfiOI2jGu2PbaO7Hz4CZntuPEEqS 7cFbZFnlkTXgwdM16YclDmCDMr8uNMnsc2w

As the properties of the dictionaries suggest that they are changeable, let’s see an example to prove that they are changeable.

Input:

dict={"Name":"Lingarajtechhub","UID":554412,"RID":"A"}
print(dict["UID"])
dict={"UID":554411}
print(dict["UID"])

Output:

s9f1gSlh

These were the example of dictionaries, we will deal more with them in the upcoming topics.

Hence, we come to the end of a short and sweet topic on dictionaries in python. Hope we were able to clear all your doubts.

Please share and comment this post and wants to improve this post WhatsApp us.

Share Your Love
Avatar photo
Soham Malakar

Hello my name is Soham Malakar am currently pursuing BCA

Coding is one of my favorite hobbies.
I love to code and an enthusiast to learn different types of programming languages.
I love to get intoxicated in the world of technology and video games.
A quick learner possessing better results.

Articles: 40

Newsletter Updates

Enter your email address below to subscribe to our newsletter