0

can someone help me to fix the error to return 10 Fibonacci series numbers?

https://code.sololearn.com/cBx66qqgdMAH/?ref=app

5th Feb 2019, 12:59 PM
Pavithra Ezhumalai
Pavithra Ezhumalai - avatar
2 Answers
+ 1
It was almost good. Keep in mind that whatever is inside the while loop will repeat in each cycle. So you don't want to reset your loop variables and your list every time, put them before the while. Also pay attention to indentation, the print in the end must be indented the same level as while. def fibonacci(): prev=0 new=1 lst=[0,1] while True: u=lst[prev]+lst[new] lst.append(u) prev+=1 new+=1 if len(lst)==10: break else: continue print(lst) fibonacci()
5th Feb 2019, 7:53 PM
Tibor Santa
Tibor Santa - avatar
+ 1
Thank you so much Tibor Santa your answer helped me a lot :)
5th Feb 2019, 8:02 PM
Pavithra Ezhumalai
Pavithra Ezhumalai - avatar