why do you need to write primes ā€‹ā€‹2 times? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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 šŸ‡®šŸ‡³