David M. Synck wrote:
>
> """ This function asks the user to input any credits not shown on their
> bank statement
>
(OT I know, but just so you know, you *may* get away with using floats
for financial calculations if you're handling small numbers of floats
of roughly same order of magnitu
Dave Hansen wrote:
> I think what you want is
>
>for cr in credlist:
> credits += cr
>
> Which could also be implemented as
>
>credits = reduce(lambda x,y: x+y, credlist)
or even:
credits = sum(credlist)
Tomasz Lisowski
--
http://mail.python.org/mailman/listinfo/python-list
Glad to help. Your relevant code:
> i = 0
> for i in credlist:
> credits += credlist[i]
> i = i + 1
credlist is your list of credits, which are floating point numbers.
You use a for-loop to iterate thru this list of floating point numbers,
so each time thru the loop, the
David M. Synck wrote:
>Hi all,
>
>I am fairly new to Python and trying to figure out a syntax error
>concerning lists and iteration through the same. What I am trying to do is
>sum a list of float values and store the sum in a variable for use later.
>
>The relevant code looks like this -
>
>def
On Thu, 22 Dec 2005 19:43:15 GMT in comp.lang.python, "David M. Synck"
<[EMAIL PROTECTED]> wrote:
[...]
>temp = float(raw_input("Please enter the first credit \n"))
>
>while temp != 0:
>credlist.append(temp)
>temp = float(raw_input("Please enter the next credit \n"))
Here
David M. Synck wrote:
> Hi all,
>
> I am fairly new to Python and trying to figure out a syntax error
> concerning lists and iteration through the same. What I am trying to do is
> sum a list of float values and store the sum in a variable for use later.
>
> The relevant code looks like this -
>
Hi all,
I am fairly new to Python and trying to figure out a syntax error
concerning lists and iteration through the same. What I am trying to do is
sum a list of float values and store the sum in a variable for use later.
The relevant code looks like this -
def getCredits():
""" This func