python的内置迭代计数器

python的内置迭代计数器,python,python-2.7,iteration,Python,Python 2.7,Iteration,我想遍历一个列表,并引用我所在的迭代编号。我可以用一个简单的计数器来完成,但是有内置的函数吗 List= list(range(0,6)) count = 0 for item in List: print "This is interation ", str(count) count += 1 这就是为什么 返回枚举对象。序列必须是序列、迭代器或>其他支持迭代的对象 在迭代中,您可以执行以下操作: for index,element in enumerate(seasons

我想遍历一个列表,并引用我所在的迭代编号。我可以用一个简单的计数器来完成,但是有内置的函数吗

List= list(range(0,6))
count = 0
for item in List:
    print "This is interation ", str(count)
    count += 1
这就是为什么

返回枚举对象。序列必须是序列、迭代器或>其他支持迭代的对象

在迭代中,您可以执行以下操作:

for index,element in enumerate(seasons):
     #do stuff
这就是为什么

返回枚举对象。序列必须是序列、迭代器或>其他支持迭代的对象

在迭代中,您可以执行以下操作:

for index,element in enumerate(seasons):
     #do stuff

您应该使用内置函数。

您应该使用内置函数