+ 1

Can someone explain this python dict code?

primes = {1: 2, 2: 3, 4: 7, 7:17} print(primes[primes[4]]) ok = {1:2,2:3,3:4,4:5}#17 print(ok[ok[3]]) #prints 5

25th Apr 2021, 5:36 PM
Faithful Adeojo
Faithful Adeojo - avatar
3 ответов
+ 3
FADE primes[4] = 7 primes[primes[4]] = primes[7] = 17 ok[3] = 4 ok[ok[3]] = ok[4] = 5
25th Apr 2021, 5:40 PM
A͢J
A͢J - avatar
+ 2
🅰🅹 (Challenge Accepted) but how does ok[3] = to 4 and how does primes[7] = 17?
25th Apr 2021, 5:43 PM
Faithful Adeojo
Faithful Adeojo - avatar
+ 2
FADE It's a dictionary in which key 4 have value 7 and key 7 have value 17 So primes [4] = 7 And now primes[7] will be 17 Same for ok[3]
25th Apr 2021, 5:50 PM
A͢J
A͢J - avatar