how to use dictionaries in python 3
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
print ("dict['Name']: ", dict['Name'])
print ("dict['Age']: ", dict['Age'])
how to use dictionaries in python 3
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
print ("dict['Name']: ", dict['Name'])
print ("dict['Age']: ", dict['Age'])
dictionary data structure python
#Note: you do not need to call it dictionary, however
#A dictionary is a collection of key and value pairs that look like this
#The element before the colon( : ) is called a key, and the element after is called a value
#The key can be any data type and the value can be any data type
dictionary = {'key':'treasure', 1:10}
#if I wanted to retrieve the value 'treasure' i would do this
print(dictionary['key'])
#If I wanted all the keys of my dictionary I would use the .keys() method
print(dictionary.keys())
#If I wanted all the values of my dictionary I would use the .values() method
print(dictionary.values())
#If I wanted both the keys and values of my dictionary I would use .items()
print(dictionary.items())
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