I need to do in Python the same as:
for (i = 0; i < 5; i++) {cout << i;}
but I don\'t know how to use FOR in Python to get the index
If you have an existing list and you want to loop over it and keep track of the indices you can use the enumerate function. For example
enumerate
l = ["apple", "pear", "banana"] for i, fruit in enumerate(l): print "index", i, "is", fruit