Why this code is showing intended error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this code is showing intended error

num = int(input()) def fibonacci(n): if n < 1: return 0 elif n<=1: return 1 else : return fibonacci (n-1)+ fibonacci (n-2) for n in range (0,num): print (fibonacci(n)) fibonacci(num)

14th Feb 2021, 11:53 AM
Meghna Kundu
Meghna Kundu - avatar
2 Answers
+ 1
By the way, the interpreter will always let you know what line(s) the error has occured, you can always adjust and align the indentations. ✌️
14th Feb 2021, 12:09 PM
noteve
noteve - avatar
0
Because of the 'if' and 'for'. Though just fixing the 'if' and 'for' will make the code work, it is still considered a bad practice if you used different indentations inside each block of codes. https://code.sololearn.com/caQGx21ZTl0d/?ref=app But try to have consistent indentation on your code to improve readability. Here's a code which uses the same indentation each block (cleaner and more readable). https://code.sololearn.com/clcK0m5cBUDR/?ref=app .
14th Feb 2021, 11:59 AM
noteve
noteve - avatar