In :
def endgame():
fibOne = int(input("Enter number of terms: "))
fib1, fib2 = 0, 1 # firts and second term of fibbonachi sequence
i = 0  #variable for loop

if fibOne <= 0:
print("Please enter a positive integer")
elif fibOne == 1:
print("Fibonacci sequence upto",fibOne,":")
print(fib1)
elif fibOne >= 10000:
print("you're only hurting yourself with that")
endgame()
else:
print("Fibonacci sequence:")
for i in range(fibOne):  #for loop upto fibth term
print(fib1)
sum = fib1 + fib2  #equation for the fibonacci series
fib1 = fib2
fib2 = sum
i += 1
Retry = input("Would you like to try and input another number agian?(y/n) >")
if(Retry == "y"):
print("going back")
endgame()
if(Retry == "n"):
print("have a great day")
exit()
endgame()

Enter number of terms: 7
Fibonacci sequence:
0
1
1
2
3
5
8
Would you like to try and input another number agian?(y/n) >y
going back
Enter number of terms: 3
Fibonacci sequence:
0
1
1
Would you like to try and input another number agian?(y/n) >n
have a great day

In [ ]:


In [ ]:


Home