[Tutor] Is this correct syntax for what I want?
Alan Gauld
alan.gauld at freenet.co.uk
Fri Jun 23 23:05:19 CEST 2006
> 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 members of the
tuples.
Therefore I assume you have something like:
mydata = [(1,2),(3,4)]
and you want to add 7 to, say, 4.
But do you want the end result to be an updated mydata:
mydata = [(1,2),(3,11)]
Or do you only want to store the resuilt of the addition
somewhere, like this:
myvar = mydata[1][1] + 7
which leaves mydata unchanged.
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list