Sorry for the simplicity of my questions, but is enumerate a way around using while loops
my while loop is this:
- x = 1
-
>>> while x < len(rate):
-
... try:
-
... growth.append(rate[x])
-
... x += 3
-
... except IndexError:
-
... break
-
...
thanks
a better way to create a while loop (IMO) is using infinity loop.
eg
-
while 1:
-
#statements...
-
if some condition:
-
break
-
if another condition:
-
break
-
this way, you can customize your loop according to different conditions, whereas in your example, you can only exit while loop on x>len(rate).
and as to your question, enumerate() works on iterable objects, ie range(), open files, etc.. see
here.