Python Program not running ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python Program not running ?

def check_fibonacci(num): a, b = 0, 1 c = num * 2 for i in range(c): if i == num: return True else: a, b = b, a+b else: return False def fibonacci_range(a, b): m = [] while a < b: if check_fibonacci(a) == True: m.append(a) else: a += 1 return m print(fibonacci_range(8, 16))

21st Apr 2019, 3:40 PM
Prince Gupta
Prince Gupta - avatar
4 Answers
+ 1
So. When i tried to run i had a indentation error in the second function. After solving this your code always give to me Time exceed. I believe the False return statement is not being reached in first function.
21st Apr 2019, 4:06 PM
Anya
Anya - avatar
+ 1
Prince Gupta Firstly it needs to get rid of the infinite loop: while a < b: if check_fibonacci(a) == True: m.append(a) else: a += 1 ... When check_fibonacci(a) == True, 'a' stays unchanged and the loop never ends.
21st Apr 2019, 4:13 PM
portpass
+ 1
The function prints Fibonacci series in a range
21st Apr 2019, 4:24 PM
Prince Gupta
Prince Gupta - avatar
+ 1
Running it The problem is only in the if statement Why Also pls fix it
21st Apr 2019, 4:25 PM
Prince Gupta
Prince Gupta - avatar