Sep-26-2018, 01:53 PM
Hey i have this code which should print out fibonaccis sequence yet encounter the following error.
Error:Traceback (most recent call last):
File "C:\Users\Louis\csyr9\fibonacci.py", line 12, in <module>
fibonacci()
File "C:\Users\Louis\csyr9\fibonacci.py", line 5, in fibonacci
while a <= 20:
UnboundLocalError: local variable 'a' referenced before assignment
here is the code:a = 1 b = 2 def fibonacci(): while a <= 20: c = a+b d = b+c print (a,b,c,d) a = c b = d fibonacci()how do i fix this? thanks