[Tutor] Python Help (shits killing me)
Ben Placella
benjamin.placella at maine.edu
Thu Oct 25 18:13:31 EDT 2018
So I have to make a fibonacci sequence, and I'm not sure what is wrong with
my code
#This program illustrates the fibonacci sequence
nterms=int(input("Please enter how many terms you would like to know: "))
n1 = 1
n2 = 1
count = 0
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence upto",nterms,":")
while count < nterms:
print(n1,end=' , ')
nth = n1 + n
n1 = n2
n2 = nth
count += 1
attached is a photo of what the output SHOULD look like
More information about the Tutor
mailing list