How do I loop through a Python list by twos?
- by froadie
I want to loop through a Python list and process 2 list items at a time. Something like this in another language:
for(int i = 0; i < list.length(); i+=2)
{
// do something with list[i] and list[i + 1]
}
What's the best way to accomplish this?