multiple ranges to for statement?
Damian Menscher
menscher+python at uiuc.edu
Tue Apr 9 02:33:04 EDT 2002
I'm hoping to do something along the lines of:
for i in range(a,b),range(c,d):
stuff goes here
But of course that sets i to the *two* values: range(a,b) and
range(c,d). Is there a simple way to get it to take on every value
from a to b and then every value from c to d? I would think there
should be, but I'm a newbie and can't figure it out.
So far, the best I can think of would be:
values = range(a,b)
for i in range(c,d):
values.append(i)
for i in values:
stuff goes here
It just doesn't seem very clean, so I'm wondering if I'm missing
something obvious.
Damian Menscher
--
-=#| Physics Grad Student & SysAdmin @ U Illinois Urbana-Champaign |#=-
-=#| 488 LLP, 1110 W. Green St, Urbana, IL 61801 Ofc:(217)333-0038 |#=-
-=#| 1412C DCL, Workstation Services Group, CCSO Ofc:(217)244-3862 |#=-
-=#| <menscher at uiuc.edu> www.uiuc.edu/~menscher/ Fax:(217)333-9819 |#=-
More information about the Python-list
mailing list