Re: [Tutor] Loop in pre-defined blocks

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016 at 6:28 PM Alan Gauld via Tutor wrote: > On 13/06/16 08:46, Ek Esawi wrote: > > Here is a beginner code that might work for you. Best of luck. EK > > > > b=[12, 20, 35] > > > > for i in range(len(b)): > > if i==0: > > c=0 > > else: > >

Re: [Tutor] Loop in pre-defined blocks

2016-06-13 Thread Ek Esawi
OPS! This code now produces desired results. I suppose that this works for smaller blocks. For larger blocks, it might be cumbersome. EK b=[12, 20, 35] for i in range(len(b)): if i==0: c=0 elif i==2: c=24 else: c=b[i-1] for j in range(c, b[i]):

Re: [Tutor] Loop in pre-defined blocks

2016-06-13 Thread Alan Gauld via Tutor
On 13/06/16 08:46, Ek Esawi wrote: > Here is a beginner code that might work for you. Best of luck. EK > > b=[12, 20, 35] > > for i in range(len(b)): > if i==0: > c=0 > else: > c=b[i-1] > for j in range(c, b[i]): > print(i+1,j+1) The problem here

Re: [Tutor] Loop in pre-defined blocks

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016 at 1:33 PM Ek Esawi wrote: > Here is a beginner code that might work for you. Best of luck. EK > > b=[12, 20, 35] > > for i in range(len(b)): > if i==0: > c=0 > else: > c=b[i-1] > for j in range(c, b[i]): >

Re: [Tutor] Loop in pre-defined blocks

2016-06-13 Thread Ek Esawi
Here is a beginner code that might work for you. Best of luck. EK b=[12, 20, 35] for i in range(len(b)): if i==0: c=0 else: c=b[i-1] for j in range(c, b[i]): print(i+1,j+1) ___ Tutor maillist -

Re: [Tutor] Loop in pre-defined blocks

2016-06-10 Thread Jignesh Sutar
Sorry, to be a little bit more descriptive. I'd like to loop from 1 to 35 but within this loop there are divisions which I need to prefix that particular division number. My output would look like this: 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 3

Re: [Tutor] Loop in pre-defined blocks

2016-06-10 Thread Alan Gauld via Tutor
On 10/06/16 23:43, Jignesh Sutar wrote: > Is there a better way to code the below than to specify blocks as I have. > Ideally I'd like to specify blocks simply as *blocks=(12,20,35)* > > blocks=[(1,12), (13,20), (25,35)] > for i,j in enumerate(blocks): > for x in

[Tutor] Loop in pre-defined blocks

2016-06-10 Thread Jignesh Sutar
Is there a better way to code the below than to specify blocks as I have. Ideally I'd like to specify blocks simply as *blocks=(12,20,35)* blocks=[(1,12), (13,20), (25,35)] for i,j in enumerate(blocks): for x in xrange(blocks[i][0],blocks[i][1]+1): print i+1, x Thanks in advance.