[Tutor] Python Help (shits killing me)
Andrew Van Valkenburg
andrew.vanvalkenburg at gmail.com
Fri Oct 26 06:15:30 EDT 2018
nth = n1 + n
I don't see where n is defined anywhere. Should be n2?
On Fri, Oct 26, 2018 at 6:09 AM Ben Placella <benjamin.placella at maine.edu>
wrote:
> 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
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list