0

I need help with lists and dictionaries.

So, I am currently learning in the python course and currently I'm experiencing some troubles with lists & dictionaries. There is probably just something that is super simple that I don't see, but here it is. So, during the questions of the dictionary stuff it keeps asking questions about the results of code with print(name[name[1]]) and I don't understand why they put the key/value location behind name in the print command, if I could get help on this it would be appreciated.

12th Feb 2019, 1:53 AM
blink3d
blink3d - avatar
2 Answers
+ 2
The result of name[1] is used as a key to get another item from the dictionary: name = {0: 1, 1: 2, 2: 3, 3: 4, 4: 5} print(name[1]) #2 print(name[name[1]]) #3 #same as print(name[2]) #because name[1]=2 print(name[name[1]] == name[2]) #True: same value print(name[name[1]] is name[2]) #True: same object
12th Feb 2019, 6:11 AM
Anna
Anna - avatar
0
Thanks! Hopefully this works, looks pretty legit.
12th Feb 2019, 8:15 PM
blink3d
blink3d - avatar