Python dictionaries

72 Views
Published
Python dictionaries tutorial explained

#dictionary = A changeable, unordered collection of unique key:value pairs
# Fast because they use hashing, allow us to access a value quickly

capitals = {'USA':'Washington DC',
'India':'New Dehli',
'China':'Beijing',
'Russia':'Moscow'}

#capitals.update({'Germany':'Berlin'})
#capitals.update({'USA':'Las Vegas'})
#capitals.pop('China')
#capitals.clear()

#print(capitals['Germany'])
#print(capitals.get('Germany'))
#print(capitals.keys())
#print(capitals.values())
#print(capitals.items())

for key,value in capitals.items():
print(key, value)

#python #dictionaries #dictionary

––––––––––––––––––––––––––––––
Up In My Jam (All Of A Sudden) by - Kubbi https://soundcloud.com/kubbi
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library https://youtu.be/tDexBj46oNI
––––––––––––––––––––––––––––––
Category
Bro Code
Tags
Python, Python Dictionary, Python dict
Be the first to comment