Previous Lecture Complete and continue  

  Lesson 13: English Dictionary? NO. Python Dictionary.

22 comments
Krystal Mills
Could I write code that would pull a list offline and then put it in a dictionary for me?
Katie Stotts
#dictionaries
#DICT[key]-->value
#{key1: value1, key2: value2,...etc]

phone_book= {"katie": "502-645-3333", "tyler":"502-645-9999"}
print(phone_book["katie"])
print(phone_book["katie"])

nothing was showing up on the right side..what am I doing wrong?
Robert Pärnpuu
Everything should be fine. Try putting the code into IDLE becuase repl.it just doesn't work for me and maybe doesn't for you either. I copy pasted your code into IDLE and it worked perfectly
Wontaek Oh
you need to replace " to '
Robert Pärnpuu
No she doesn't. Python accepts both " and ' with no difference in result
goutham kumar
https://repl.it/GAc6
Christian Sampsell
How could you save specific profiles of these in Idle so that you can just say "print(phoneBook ['me'] [0])" whenever you wanted even after you've closed and reopened Idle?
Ivan K.
Tried mixing the append and dictionary topics together:

phone_book = {
'name1' : ['123-456-7890', [email protected]'],
'name2' : ['123-789-4560'],
'name3' : ['123-123-4567']
}
print(phone_book['name1'])

new_details = ['777-888-9999', [email protected]']
print(new_details)

new_details1 = ['800-900-1111', [email protected]']
print(new_details1)

print(new_details1[0])
print(new_details1[1])

for i in range(0,2):
phone_book['name1'].append(new_details[i])
print(phone_book['name1'])

for i in range(0,2):
phone_book['name2'].append(new_details1[i])
print(phone_book['name2'])
Modasir Khajazada
phonebook={
'police':['911',[email protected]'],
'airport':['100',[email protected]'],
'ambulance':['999',[email protected]']
}
print(phonebook['police'][0])
print(phonebook['police'][1])
print(phonebook['airport'][0])
print(phonebook['airport'][1])
print(phonebook['ambulance'][0])
print(phonebook['ambulance'][1])
poonam ahir
nice...
Danny B
phone_book={ 'bob':['9827375283964', '21 guava st', [email protected]', 'USA'],
"pete":['2352345726348', '345,hoer',[email protected]', 'Canada'],
'mike':['56723647286348', '45 dover',[email protected]', 'mexico']
}
>>> print(phone_book['mike'])
['56723647286348', '45 dover', [email protected]', 'mexico']

premier_league_table_points={ 'Manchester United': '33','Chelsea': '46', 'Liverpool':'40', 'Man.City':'39', 'Arsenal':'37'


}
>>> print(premier_league_table_points['Man.City'])
39
Théo Michel
Ahaha that's nice

Aly Abo Ouf
https://repl.it/Ewl2/0
Ali
nice work
Ali
https://repl.it/FBVb/2
Zsolt Bisztray
https://repl.it/FBVb/2
Ereatara Kokiri
man that was hard
# dictionaries
# DICT[key] --> value
# LIST[0] --> first element of the list
# { key1: value1, key2: value2,...}

phone_book = {
'qazi': ['123-456-7890',[email protected]'],
'bob': ['222-222-2222', [email protected]'],
'cat': ['333-333-3333', [email protected]']
}

print(phone_book['qazi'][0])
print(phone_book['bob'][0])
print(phone_book['cat'][0])

# DICT[qazi] --> list of things containing ph# and email.
Sebastian Gomez
phone_book = {
"rodrigo":["12223","hotmail","H.St"],
"Rebeca":["12353","gmail","7.St"],
"Fatima":["43129","yahoo","Frez. St"]
}
Rebeca= phone_book["Rebeca"]
Rodrigo= phone_book["rodrigo"]
Fatima= phone_book["Fatima"]

print (Rebeca[0])
print(Rodrigo[1])
print(Fatima[2])
Hatim Elsadig Elamin Elhag
phonebook={
'police':['911',[email protected]'],
'airport':['100',[email protected]'],
'ambulance':['999',[email protected]']
}
print(phonebook['police'][0])
print(phonebook['police'][1])
print(phonebook['airport'][0])
print(phonebook['airport'][1])
print(phonebook['ambulance'][0])
print(phonebook['ambulance'][1])
Raitis Osis
Premier_league={
'Arsenal':['Sanchez',[email protected]', '1st'],
'Chelsea':['Oscar', [email protected]', '2nd'],
'ManU': ['Rooney', [email protected]', '3rd']
}

print(Premier_league['Arsenal'][1])
print(Premier_league['Arsenal'][0])
print(Premier_league['ManU'][2])
print(Premier_league['Chelsea'][2])
Marko Milovanovic
imenik={
"marko":["09888788", "[email protected]", "vuka karadzica"],
"slavica":["87878", "[email protected]", "rade sisk"],
"fixni":["7655556", "[email protected]", "gutiona durta"]}
marko, slavica, fixni=imenik
print(imenik[fixni][0])
print(imenik[slavica][2])
print(imenik[marko][1])
Dan Long
phonebook = ['07968530822', '999']
phonebook[0]
phonebook[1]
phonebook = {
'dan': ['07968530822',[email protected]'],
'police' : ['999', [email protected]']
}

print(phonebook['dan'][0])

print(phonebook['dan'][1])
print(phonebook['police'])
print(phonebook['police'][1])