0
Problem with list in funktions and loops
Today I tried to solve the âFibonacciâ challenge in the Python course. Will doing it an error accrued I didnât understood. When I tried to get an value out of an List using its index in an funktion or loop caused an error. Doing it outside on didnât. That makes no sense for me, but hopefully for you. https://code.sololearn.com/cH3c2i0ud3c6/?ref=app
2 Answers
+ 1
List=List.append(c) is the problem. List.append(c) adds c to List without returning anything so List.append(c) by itself is enough. Also, don't forget to decrease n unless you want infinite recursion.
0
As jtrh already mentioned, append() works inplace and does not return. You can decrease n in line 12 by using (n-2) in calling the function.