[Tutor] A bit long, but would appreciate anyone's help, if time permits! (original) (raw)
Roel Schroeven rschroev_nospam_ml at fastmail.fm
Sat Jul 24 22:01:11 CEST 2004
- Previous message: [Tutor] A bit long, but would appreciate anyone's help, if time permits!
- Next message: [Tutor] Re: Your advice, please [raw_input(), higher order functions]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Roel Schroeven wrote:
Just add this to the end of normal(s):
transposed = zip(*v) print '\n', transposed withindices = zip(transposed, range(len(transposed))) result = min(withindices)[1] print '\n\n', result, r[result]Instead of transposing via zip(*v) it might also be possible to generate the data in that way in the first place.
I just took a closer look at your code, and I noticed your list q contains exactly what you need. That means you don't need the first zip, you can just do
withindices = zip(q, range(len(q)))
result = min(withindices)[1]Or alternatively, maybe it's better not to keep track of the indices and just do a search in the list:
result = q.index(min(q))-- "Codito ergo sum" Roel Schroeven
- Previous message: [Tutor] A bit long, but would appreciate anyone's help, if time permits!
- Next message: [Tutor] Re: Your advice, please [raw_input(), higher order functions]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]