In article <[EMAIL PROTECTED]>, Dan Sommers  <[EMAIL PROTECTED]> wrote:
>Perhaps not the prettiest, but I can't think of anything simpler to read
>six months from now:
>
>    counter = 0
>    for an_element in the_list:
>        print an_element,
>        counter = counter + 1
>        if counter == n:
>            print
>            counter = 0

for counter, an_element in enumerate(the_list):
    print an_element,
    if not (counter+1) % n:
        print
# Plus the final print fixed in an earlier follow-up:
if len(the_list) % n:
    print

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to