1
The get(key, default) function returns the value in the map according to the key key specific.
On the map we have the following keys: 1, 2, 3, 4
, and their values are as follows:: 1, 1, 2, 3
In the example:
fib.get(4, 0)
Will recover the value who holds the key 4, in the case, the value 3. If it did not exist in the key map with this value would be returned the value 0.
fib.get(7, 5)
Will recover the value who holds the key 7, as there is no value on the map with this key will be returned the default value 5
As a result then we have 3 + 5 = 8
A teaching reference: https://www.tutorialspoint.com/python/dictionary_get.htm
Thank you very much. Now I understand perfectly. Vlw.
– Fenix
I am happy to know that I could help. I thank you for accepting the answer. Good studies!
– escapistabr