+ 2

Python Dictionaries

Can some one explain me Python Dictionaries?

13th Sep 2020, 10:52 AM
Jash Sampat
7 Respuestas
+ 2
i like to think of dictionaries as a big box with a bunch of smaller boxes inside, each labeled. Theres no rhyme or reason how they are put in there so its not naturally ordered. to access, the contents you want, you'll need to know the label name. the label is the key and the contents is the value in the key:value pair. say if you worked at a shelter, you can have a dictionary called "animals". in that dictionary you can put animal types (dog, cat, pig, whatever) as the keys. Just string values as labels that point to the value, probably how many you have of each
13th Sep 2020, 11:02 AM
Slick
Slick - avatar
13th Sep 2020, 11:01 AM
Lothar
Lothar - avatar
+ 5
It is just like your English dictionary where we store a key with its value whenever we require to see the value then we need to search for key Ex D = {key:value,key:value} D[key] will give value
13th Sep 2020, 11:02 AM
Ayush Kumar
Ayush Kumar - avatar
13th Sep 2020, 11:00 AM
Jayakrishna 🇮🇳
0
Dictionaries are just like lists. But in dictionaries we have to assign the elements to something known as keys while in lists, the elements are automatically indexed.
27th Sep 2020, 8:05 AM
Prabhat Limbu
Prabhat Limbu - avatar
0
this was totally hard, thanks
23rd Oct 2020, 11:07 AM
Sohial
Sohial - avatar