[Tutor] Problems with iterations and breaking loops.
Alan Gauld
alan.gauld at btinternet.com
Wed Mar 17 19:20:11 CET 2010
"Karjer Jdfjdf" <karper12345 at yahoo.com> wrote
> I have a list of tuples with 2 values.
> I want to perform calculations on all of these
> for each value in a range of values (e.g. 100 to 110).
So, if I understand you correctly, you want to
write a function
perform_calculations(value, list_of_tuples, ):
for v1,v2 in list_of_tuples:
# something = calculate( value, v1, v2)
return something
Then you iterate over your values:
results = [perform_calculations(value, list_of_tuples) for value in
range(min,max+!)]
results should then be a list of results (which might in turn be tuples or
lists)
Does that work for you?
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list