Re: [Tutor] Iterate Suggestion

2012-04-16 Thread bob gailer
On 4/15/2012 10:54 PM, bob gailer wrote: On 4/14/2012 11:27 AM, Tom Tucker wrote: Hello all. Any suggestions how I could easily iterate over a list and print the output 3 across (when possible)? One method I was considering was removing the recently printed item from the list, checking lis

Re: [Tutor] Iterate Suggestion

2012-04-15 Thread Peter Otten
Tom Tucker wrote: > Hello all. Any suggestions how I could easily iterate over a list and > print the output 3 across (when possible)? One method I was considering > was removing the recently printed item from the list, checking list > length, > etc. Based on the remaining length of the list I

Re: [Tutor] Iterate Suggestion

2012-04-15 Thread bob gailer
On 4/14/2012 11:27 AM, Tom Tucker wrote: Hello all. Any suggestions how I could easily iterate over a list and print the output 3 across (when possible)? One method I was considering was removing the recently printed item from the list, checking list length, etc. Based on the remaining len

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Steven D'Aprano
Bod Soutar wrote: How about something like this mylist = ['serverA', 'serverB', 'serverC', 'serverD','serverE', 'serverF', 'serverG'] tempstr = "" count = 0 for item in mylist: count += 1 if count == 3: tempstr += (i + "\n") count = 0 else: tempstr += (i +

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Dave Angel
On 04/14/2012 01:55 PM, Tom Tucker wrote: > All, > Thanks for the help. Please try to post your messages AFTER the part you're quoting. Another very useful feature is enumerate(). Instead of doing for item in mylist: count += 1 if count... do something like: for index, item in enum

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Tom Tucker
All, Thanks for the help. On Sat, Apr 14, 2012 at 1:33 PM, Bod Soutar wrote: > > > On 14 April 2012 18:29, Bod Soutar wrote: > >> >> >> On 14 April 2012 16:27, Tom Tucker wrote: >> >>> >>> Hello all. Any suggestions how I could easily iterate over a list and >>> print the output 3 across (whe

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Bod Soutar
On 14 April 2012 18:29, Bod Soutar wrote: > > > On 14 April 2012 16:27, Tom Tucker wrote: > >> >> Hello all. Any suggestions how I could easily iterate over a list and >> print the output 3 across (when possible)? One method I was considering >> was removing the recently printed item from the

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Bod Soutar
On 14 April 2012 16:27, Tom Tucker wrote: > > Hello all. Any suggestions how I could easily iterate over a list and > print the output 3 across (when possible)? One method I was considering > was removing the recently printed item from the list, checking list length, > etc. Based on the remain

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Alan Gauld
On 14/04/12 16:27, Tom Tucker wrote: Hello all. Any suggestions how I could easily iterate over a list and print the output 3 across (when possible)? Using the step size argument to range: L = range(12) >>> for n in range(0,len(L),3): ...print L[n],L[n+1],L[n+2] ... 0 1 2 3 4 5 6 7 8 9

[Tutor] Iterate Suggestion

2012-04-14 Thread Tom Tucker
Hello all. Any suggestions how I could easily iterate over a list and print the output 3 across (when possible)? One method I was considering was removing the recently printed item from the list, checking list length, etc. Based on the remaining length of the list I would then print X across. Ya