python dict
mydictionary = {'name':'python', 'category':'programming', 'topic':'examples'}
for x in mydictionary:
print(x, ':', mydictionary[x])
python dict
mydictionary = {'name':'python', 'category':'programming', 'topic':'examples'}
for x in mydictionary:
print(x, ':', mydictionary[x])
Python Dictionaries
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict["brand"])
python Dictionaries
#Python dictionaries consists of key value pairs tha
#The following is an example of dictionary
state_capitals = {
'Arkansas': 'Little Rock',
'Colorado': 'Denver',
'California': 'Sacramento',
'Georgia': 'Atlanta'
}
#Adding items to dictionary
#Modification of the dictionary can be done in similar maner
state_capitals['Kampala'] = 'Uganda' #Kampala is the key and Uganda is the value
#Interating over a python dictionary
for k in state_capitals.keys():
print('{} is the capital of {}'.format(state_capitals[k], k))
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