[Tutor] skipping ahead within a loop

Jorgen Bodde jorgen.maillist at gmail.com
Thu Mar 15 15:34:49 CET 2007


Maybe use a while loop?

y = 0
while y < HEIGHT:
    linewidth = random(3,9)
    y += linewidth

Regards,
- Jorgen

On 3/15/07, Clay Wiedemann <clay.wiedemann at gmail.com> wrote:
> If  doing a loop, how can one skip forward a specific amount randomly
> determined within the loop?
> Below is a boiled down version of what I am trying (HEIGHT and random
> come from NodeBox). I imagine a simple solution is out there, my
> searches failed me
>
>
> for y in range(HEIGHT):
>         linewidth = random(3, 9)
>         # drawlines, etc.
>         y += linewidth  # this is what does not work
>
>
>
> Thanks,
> Clay
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list