Python enumerate built-in error when using the start parameter
Posted
by TheJuice
on Stack Overflow
See other posts from Stack Overflow
or by TheJuice
Published on 2010-03-31T11:04:17Z
Indexed on
2010/03/31
11:13 UTC
Read the original article
Hit count: 416
I'm modifying some code that calls enumerate on a list declared via a list comprehension e.g.
self.groups = [Groups(self, idx) for idx in range(n_groups)]
then later:
for idx, group in enumerate(self.groups):
# do some stuff
but when I change the enumerate call to start at the 2nd list element via the start parameter e.g.
for idx, group in enumerate(self.groups[1]):
I get an exception:
exceptions.TypeError: 'Group' object is not iterable
Could someone explain why this is?
© Stack Overflow or respective owner