> File "C:\Python24\Account Tracker.py", line 10, in load_file
>amount = line.next().strip()
> AttributeError: 'str' object has no attribute 'next'
>
> According to it, the 'str' object has no attribute 'next'. So how
> would I load my file containing my data?
The str object in question is l
Message -
From: "Alan Gauld" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>;
Sent: Sunday, June 25, 2006 1:07 AM
Subject: Re: [Tutor] Is this correct syntax for what I want?
>> File "C:\Python24\Account Tracker.py", line 49, in pri
Thanks, it works now perfectly! Thanks for all the help!
- Original Message -
From: "Alan Gauld" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>;
Sent: Sunday, June 25, 2006 1:07 AM
Subject: Re: [Tutor] Is this correct syntax for what I want?
> File "C:\Python24\Account Tracker.py", line 49, in printall
>print account,"\t $",accountlist[account]+"\n"
> TypeError: unsupported operand type(s) for +: 'float' and 'str'
>
> So how do I fix this error?
What it's saying is you can't add a float and string. If you
look at the code you a
: "Nathan Pinno" <[EMAIL PROTECTED]>;
Sent: Saturday, June 24, 2006 3:54 PM
Subject: Re: [Tutor] Is this correct syntax for what I want?
>
>> The data structure is:
>> mydata = [(Checking, 12.50),(Savings, 34.50)] And I want the result to
>> look like this:
&
> The data structure is:
> mydata = [(Checking, 12.50),(Savings, 34.50)]
>
> And I want the result to look like this:
> mydata = [(Checking, 19.50),(Savings, 34.50)]
>
> So how do I do this?
OK, The problem is that you cannot change the contents of a
tuple, you can only create a new tuple. The
> The data is account name and 12.50 (example).
> I want to access the data to add and subtract from it.
> For example
> 12.50 - 2.25 = 10.25
> 10.25 + 4.75 = 15.00
Sorry, I meant the data structures. You mentioned you had a list of
tuples?
And you wanted to perform addition./subtraction on memb
<[EMAIL PROTECTED]>;
Sent: Friday, June 23, 2006 2:48 PM
Subject: Re: [Tutor] Is this correct syntax for what I want?
> Nathan,
>
> Can you show us an example of the data?
> And what you want to do to it, ie before and after values.
>
> Its not clear to me whether you want to
the data to use in an addition/subrtraction storing
the result elsewhere (which is perfectly possible)
Alan G.
- Original Message -
From: "Nathan Pinno" <[EMAIL PROTECTED]>
To:
Sent: Friday, June 23, 2006 2:20 AM
Subject: [Tutor] Is this correct syntax for what I want?
I
You can do:
letterlist[x] += amount
letterlist[x] -= amount
Cheers,
--
murtog_
[ http://murtog.blogspot.com ]
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On Thu, 22 Jun 2006, Nathan Pinno wrote:
> I want to be able to add and subtract from a number in a tuple in a
> list. Is this the correct syntax?
>
> letterlist[x] = letterlist[x] + amount # for addition
>
> letterlist[x] = letterlist[x] - amount # for subtraction
Try it.
I want to be able to add and subtract from a number
in a tuple in a list. Is this the correct syntax?
letterlist[x] = letterlist[x] + amount # for
addition
letterlist[x] = letterlist[x] - amount # for
subtraction
If this is not correct, what is the correct
syntax?
Thanks,
Nathan Pinn
12 matches
Mail list logo