+ 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))
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.
+ 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.
+ 1
The function prints Fibonacci series in a range
+ 1
Running it
The problem is only in the if statement
Why
Also pls fix it