Re: [Tutor] for: how to skip items

2014-02-18 Thread Neil Cerutti
On 2014-02-17, Oscar Benjamin wrote: > On 17 February 2014 16:17, Gabriele Brambilla > wrote: >> Doesn't exist a way in Python to do like in C >> >> for i=0, i<100, i=i+10 >> >> ? without creating a list of index? > > You haven't said which Python version you're using. In Python 2 > the range func

Re: [Tutor] for: how to skip items

2014-02-17 Thread Dave Angel
Gabriele Brambilla Wrote in message: > in the end I'm using something like this and it works: > zipPARApha = zip(Pampli, Pgamma, Pecut, Pb, g) > for n, (a1,b1,c1,d1,pha) in enumerate(zipPARApha): > where the arguments of zip are lists of the same size. Simpler would be: for a1,b1,c1,d1,pha

Re: [Tutor] for: how to skip items

2014-02-17 Thread Andreas Perstinger
Gabriele Brambilla wrote: >it's because my problem is not so simple: >imagine that in a100 contains not integer sorted in a good way but a >random float numbers. >How could I display only one item every 10? You can provide a step size if you slice a list: >>> l = list(range(10)) >>> l[0:10:2] [0

Re: [Tutor] for: how to skip items

2014-02-17 Thread emile
On 02/17/2014 08:05 AM, Gabriele Brambilla wrote: Hi, I'm wondering how I can (if I can) make a for loop in which I don't use all the elements. for example a100 = list(range(100)) for a in a100: print(a) it print out to me all the numbers from 0 to 99 But if I want to display o

Re: [Tutor] for: how to skip items

2014-02-17 Thread Mark Lawrence
On 17/02/2014 16:17, Gabriele Brambilla wrote: Doesn't exist a way in Python to do like in C for i=0, i<100, i=i+10 ? without creating a list of index? Gabriele 2014-02-17 11:15 GMT-05:00 David Palao mailto:dpalao.pyt...@gmail.com>>: Hi Gabriele, Without knowing the details of what

Re: [Tutor] for: how to skip items

2014-02-17 Thread Gabriele Brambilla
thanks, in the end I'm using something like this and it works: zipPARApha = zip(Pampli, Pgamma, Pecut, Pb, g) for n, (a1,b1,c1,d1,pha) in enumerate(zipPARApha): where the arguments of zip are lists of the same size. Gabriele 2014-02-17 11:19 GMT-05:00 Oscar Benjamin : > On 17 February 2014 1

Re: [Tutor] for: how to skip items

2014-02-17 Thread Oscar Benjamin
On 17 February 2014 16:17, Gabriele Brambilla wrote: > Doesn't exist a way in Python to do like in C > > for i=0, i<100, i=i+10 > > ? without creating a list of index? You haven't said which Python version you're using. In Python 2 the range function returns a list but the xrange function returns

Re: [Tutor] for: how to skip items

2014-02-17 Thread Gabriele Brambilla
No sorry, it's because my problem is not so simple: imagine that in a100 contains not integer sorted in a good way but a random float numbers. How could I display only one item every 10? thanks Gabriele 2014-02-17 11:08 GMT-05:00 Oscar Benjamin : > On 17 February 2014 16:05, Gabriele Brambill

Re: [Tutor] for: how to skip items

2014-02-17 Thread Oscar Benjamin
On 17 February 2014 16:13, Gabriele Brambilla wrote: > No sorry, > > it's because my problem is not so simple: > imagine that in a100 contains not integer sorted in a good way but a random > float numbers. > How could I display only one item every 10? for n, a in enumerate(a100): if n % 10 ==

Re: [Tutor] for: how to skip items

2014-02-17 Thread Gabriele Brambilla
Doesn't exist a way in Python to do like in C for i=0, i<100, i=i+10 ? without creating a list of index? Gabriele 2014-02-17 11:15 GMT-05:00 David Palao : > Hi Gabriele, > Without knowing the details of what you are trying, I guess you could > be interested in looking at how to define your ow

Re: [Tutor] for: how to skip items

2014-02-17 Thread David Palao
Hi Gabriele, Without knowing the details of what you are trying, I guess you could be interested in looking at how to define your own iterators. Regards 2014-02-17 17:05 GMT+01:00 Gabriele Brambilla : > Hi, > > I'm wondering how I can (if I can) make a for loop in which I don't use all > the elem

Re: [Tutor] for: how to skip items

2014-02-17 Thread Gabriele Brambilla
Excuse me for the bad english: not "a random float numbers" but "random float numbers" Gabriele 2014-02-17 11:13 GMT-05:00 Gabriele Brambilla < gb.gabrielebrambi...@gmail.com>: > No sorry, > > it's because my problem is not so simple: > imagine that in a100 contains not integer sorted in a good

Re: [Tutor] for: how to skip items

2014-02-17 Thread Joel Goldstick
On Feb 17, 2014 11:06 AM, "Gabriele Brambilla" < gb.gabrielebrambi...@gmail.com> wrote: > > Hi, > > I'm wondering how I can (if I can) make a for loop in which I don't use all the elements. > > for example > > a100 = list(range(100)) > > for a in a100: > print(a) > > it print out to me

Re: [Tutor] for: how to skip items

2014-02-17 Thread Oscar Benjamin
On 17 February 2014 16:05, Gabriele Brambilla wrote: > Hi, > > I'm wondering how I can (if I can) make a for loop in which I don't use all > the elements. > > for example > > a100 = list(range(100)) > > for a in a100: > print(a) > > it print out to me all the numbers from 0 to 99 > Bu

[Tutor] for: how to skip items

2014-02-17 Thread Gabriele Brambilla
Hi, I'm wondering how I can (if I can) make a for loop in which I don't use all the elements. for example a100 = list(range(100)) for a in a100: print(a) it print out to me all the numbers from 0 to 99 But if I want to display only the numbers 0, 9, 19, 29, 39, ...(one every 10 el