Answers for "dict python function"

1

python dict

mydictionary = {'name':'python', 'category':'programming', 'topic':'examples'}

for x in mydictionary:
	print(x, ':', mydictionary[x])
Posted by: Guest on February-27-2022
0

Python Dictionaries

thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
print(thisdict["brand"])
Posted by: Guest on February-01-2021
0

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))
Posted by: Guest on May-16-2022

Python Answers by Framework

Browse Popular Code Answers by Language