+ 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
3 odpowiedzi
+ 3
FADE
primes[4] = 7
primes[primes[4]]
= primes[7]
= 17
ok[3] = 4
ok[ok[3]] = ok[4] = 5
+ 2
🅰🅹 (Challenge Accepted) but how does ok[3] = to 4 and how does primes[7] = 17?
+ 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]