Answers for "wat is dictionary in python"

5

dictionary in python

dict = {"apple": "fruit", "ball": "object", "cricket": "sports"}

#how to print?

print(dict["cricket"])
Posted by: Guest on January-11-2022
2

dictionary in python

#A dictionary has key-value pairs. Here 1,2,3 are the keys and Item1,Item2,Item3 
#are their values respectively. 
dictionaryName = { 1: "Item1", 2: "Item2", 3: "Item3"}

#retrieving value of a particular key
dictionaryName[1]

#retrieving all the keys in a dictionary
dictionaryName.keys()

#retrieving all the values in a dictionary
dictionaryName.values()
Posted by: Guest on November-01-2020

Python Answers by Framework

Browse Popular Code Answers by Language