[Tutor] updating step size while in loop
Hugo Arts
hugo.yoshi at gmail.com
Tue Jul 10 00:06:49 CEST 2012
On Mon, Jul 9, 2012 at 11:59 PM, Abhishek Pratap <abhishek.vit at gmail.com>wrote:
> hey guys
>
> I want to know whether it is possible for dynamically update the step
> size in xrange or someother slick way.
>
> Here is what I am trying to do, if during a loop I find the x in list
> I want to skip next #n iterations.
>
>
> for x in xrange(start,stop,step):
> if x in list:
> step = 14
> else:
> step = 1
>
>
>
> Thanks!
> -Abhi
>
It is not possible with a range object. You'll have to make a while loop
and keep track of the step yourself.
Hugo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120710/f4b62924/attachment.html>
More information about the Tutor
mailing list