How do I loop through a Python list by twos?
Posted
by froadie
on Stack Overflow
See other posts from Stack Overflow
or by froadie
Published on 2010-06-07T14:00:42Z
Indexed on
2010/06/07
14:22 UTC
Read the original article
Hit count: 280
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?
© Stack Overflow or respective owner