On 6/18/07, Simon Hooper <[EMAIL PROTECTED]> wrote:
Hi Luke, * On 17/06/07, Luke Paireepinart wrote: > a more expanded version that accounts for either list being the longer > one, or both being the same length, would be: > > >>> if len(t) > len(l): x = len(t) > else: x = len(l) > >>> print [(l[i%len(l)],t[i%len(t)]) for i in range(x)] > [(1, 'r'), (2, 'g'), (3, 'b'), (4, 'r'), (5, 'g')] Being the duffer that I am, I'm very pleased with myself that I came up with a similar solution (albeit as a function rather than a list comprehension) :) You do not need the if statement either,
Yeah, I never knew about the max() function! I noticed someone else used it in one of their solutions. I'm pretty sure I've seen it a lot before, just didn't remember it. -Luke
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor