[Tutor] Python trouble
Joel Goldstick
joel.goldstick at gmail.com
Tue Dec 29 12:54:40 EST 2015
On Tue, Dec 29, 2015 at 11:52 AM, Nathan Clark <261100nc at gmail.com> wrote:
> This is a fibonnaci sequence generator, the colon causes a syntax error
>
>
> #set variables
> num_1 = 1
> num_2 = 2
> count = 0
> terms = int(input("How many terms of the fibonnaci sequence would you
> like?")
>
>
> #function
> while terms != count :
> num_3 =num_1+num_2
> print (num_3)
> num_1=num_2
> num_2 = num_3
>
this can be simplified to
num_1, num_2 = num_2, num_3
> count=count+1
> else:
> print ("finished")
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
--
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
More information about the Tutor
mailing list