After, I need a line immediately after that that will combine d1, d2 and d3 (addition) then figure out which is the lowest and drop it, or one of them if there are multiples of the same value. (or the other way around, drop the lowest and combine the rest)
But the "min(list())" outputs a string, and we all know that "integer + string = error"
Is there a way to make a array/pool/list of integers and then either compare them all and select the lowest, or just drop the lowest from it then total.
This is just a small example. I had thought using "compare()", but the large pools would have too many compare() functions to code efficiently.
RE: Python 2.6.4 - Integer list operations
Posts: Location: Joined: 01.01.70 Rank: Guest
Posted on 06-06-10 16:58
Hmm.... well I see a few things that could be revised:
dr1 = min(list('d1''d2''d3'))
probably should be
dr1 = min([d1,d2,d3])
list() takes only one argument, a sequence type such as a tuple, and converts it to a list. Additionally, enclosing the variables in ' ' will probably result in a conversion to strings. (i'm a little surprised that didnt error...)
using  will create a list and then min, will operate properly (as the object it was handed previously was wrong)
I'm a little bit confused in exactly what you're trying to do here, but here's your code re-written to do what i think you're getting at. With debugging and output: