0
Please explain the calculations
fib={1:1,2:1,3:2,4:3} print(fib.get(7,5)) Answer came : 5 . What's the background calculation?
2 ответов
+ 1
Okay I got it. Thanks
0
There is no calculation, this is only a lookup. get() checks if a key exists in the dictionary. If yes, it returns the value associated to the key. If not, the default value is returned from the second optional argument.
In your example, the key 7 is not there in fib, therefore the result is 5.