- 1

Dictionary Functions: Keys

Concerning the following code: What is the result of this code? primes = {1: 2, 2: 3, 4: 7, 7:17} print(primes[primes[4]]) I got the right answer, but I don't understand why. Without giving it away (or attempting not to), wouldn't the first "primes" be multiplied by the second "primes"? So, if it read "print(primes[primes[3]])" instead, wouldn't it be 7 * 7, or 49 for the final output? Thanks in advance! ~M

8th Jul 2017, 1:12 AM
creslin_black
1 ответ
+ 3
primes[4] return the value 7. Now, primes [7] return the value 17.
8th Jul 2017, 1:44 AM
Oscar Albornoz
Oscar Albornoz - avatar