Loops and things
Jair Trejo
jairtrejo at yahoo.com.mx
Fri Dec 14 16:06:51 EST 2007
I was wondering how and if it's possible to write a
loop in python
which updates two or more variables at a time. For
instance, something
like this in C:
for (i = 0, j = 10; i < 10 && j < 20; i++, j++) {
printf("i = %d, j = %d\n", i, j);
}
So that I would get:
i = 0, j = 0
i = 1, j = 1
i = 2, j = 2
...
...
...
i = 9, j = 19
Can this be done in Python?
Thanks.
----------
In your case, j is simply i+10; so can just write
j=i+10 inside the loop, or even use i+10 itself.
____________________________________________________________________________________
¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
http://correo.yahoo.com.mx/
More information about the Python-list
mailing list