+ 1

Why this dictionary code results 8 ?

Why this dictionary code results 8 ? what is the meaning for using (4,0) and (7,5) in dictionary ?! (in given dictionary of fib we have 4, but not (4,0) !!!, where (4,0) is come from ?!! ) https://code.sololearn.com/c1EB7fKcxEVM/#py

29th Jan 2018, 11:29 PM
NIMA
NIMA - avatar
1 Answer
+ 4
The second argument to get is the default to return, when the key lookup fails. 4 has a value of 3 and 7 doesn't so the get(4,0) returns 3 and get(7,5) returns 5. Added together you get 8.
29th Jan 2018, 11:35 PM
John Wells
John Wells - avatar