why do you need to write primes ​​2 times? | Sololearn: Learn to code for FREE!
0

why do you need to write primes ​​2 times?

Hi, Can anyone say me why this code needs to write "(prime[prime]) And everything else? What is the result of this code? primes = {1: 2, 2: 3, 4: 7, 7:17} print(primes[primes[4]]) result 17

7th May 2020, 5:21 PM
Guillermo González
2 ответов
+ 4
Ok, let's begin with primes[4] primes[4] = 7 Then we have prime[prime[4]] = prime[7] Then we have prime[7] = 17
7th May 2020, 5:23 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 1
It's not about need.. Its to understand the logic, how it is extracting the result 17 in a different in direct one way..... Inner result for primes[4] is 7 and then, primes[7] = 17 is the output...
7th May 2020, 5:25 PM
Jayakrishna 🇮🇳