Help on a summative formula

Emile van Sebille emile at fenx.com
Tue Jan 1 13:00:04 EST 2002


"Emile van Sebille" <emile at fenx.com> wrote in message
news:a0stl1$mvbot$1 at ID-11957.news.dfncis.de...
>
> "Ahimsa Consulting" <ahimsa at inext.co.za> wrote in message
> news:mailman.1009888201.18587.python-list at python.org...
> > Hi all
> > Need newbie level assistance on putting together a formula. I am trying
to
> > work out the phrasing for reading user input and adding each input to
the
> > previous input until the total is >= 150. I thought for a while the
> > Fibonacci series might help since that passes the value of one element
and
> > adds it to a previous value, so it worked fine for the first two inputs
> but
> > then went off at a tangent.
> > Any thoughts please.
> > Thanks
> > Andrew
> >
> >
>
> total = 0
> while total < 150:
>     total += raw_input("Enter a number: ")
>

Ooops, forgot to paste in the tested version:

>>> while total < 150:
...     total += int(raw_input("Enter a number: "))





More information about the Python-list mailing list