- 2
dictionaries
fib = {1: 1, 2: 1, 3: 2, 4: 3} print(fib.get(4, 0) + fib.get(7, 5)) Explain this code
1 Resposta
0
In this code
fib.get(4,0) gives you value 3 because you need value of key 4 but you put 0 so it mark 0 as null so it gives you back value of 4th key ie 3
And fib.get(7,5) gives you 5 because there is no such key with value 7 so it give back you 5 as result
Whole fib.get(4,0)+fib.get(7,5) gives you answer 8