+ 4

How this code has been solved? [SOLVED]

spam = {i : i%3 + i for i in range(1,11)} print(spam[spam[2]]) Ans. -> 5 https://code.sololearn.com/c7v45JFsJeMl/?ref=app

8th May 2019, 8:28 AM
ƈơɖɛཞ
ƈơɖɛཞ - avatar
2 Respuestas
+ 4
If you add print(spam) It will print the dictonary and there you can follow what happens. Spam[2] gets 4 and then spam[4] gets the 5 from the dictonary.
8th May 2019, 8:36 AM
Dragonxiv
Dragonxiv - avatar
+ 4
Thanks Dragonxiv
8th May 2019, 8:45 AM
ƈơɖɛཞ
ƈơɖɛཞ - avatar