dictionary in python
dict = {"apple": "fruit", "ball": "object", "cricket": "sports"}
#how to print?
print(dict["cricket"])
dictionary in python
dict = {"apple": "fruit", "ball": "object", "cricket": "sports"}
#how to print?
print(dict["cricket"])
dictionary in python
myDict = {
"Fast": "In a Quick Manner",
"Hasya": "A Coder",
"Marks": [1, 2, 5],
"anotherdict": {'hasya': 'Player'}
}
# print(myDict['Fast'])
# print(myDict['Hasya'])
myDict['Marks'] = [45, 78]
print(myDict['Marks'])
print(myDict['anotherdict']['hasya'])
dictionary in python
# Dictionaries in Python
ages = {"John": 43, "Bob": 24, "Ruth": 76} # Marked by { at beginning and a } at end
# ^^^ Has sets of keys and values, like the 'John' and 43 set. These two values must be seperated by a colon
# ^^^ Sets of values seperated by commas.
dictionary in python
Dict = {"name": 'Izhaan', "salary": 1234, "age": 23}
print("nDictionary with the use of string Keys: ")
print(Dict)
dictionary in python
#a dictionary
dict = {
"key": "value",
"other_key": "value"
}
#get a value from the dictionary using the key
print(dict["key"])
#you can also get a value from the dictionary using a normal index:
print(dict[1])
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us