Answers for "how to do a 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
1

dictionary in python

my_dict = {"key": "value", "a": 1, 2: "b"}
print(my_dict["key"])
# Output: value
print(my_dict["a"])
# Output: 1
print(my_dict[2])
# Output: b
Posted by: Guest on January-30-2021

Code answers related to "how to do a dictionary in python"

Python Answers by Framework

Browse Popular Code Answers by Language