Simplest way to iterate in pairs or more in python over a single list?
list1=['Hello ','World','.','I ','heart ','python']
Something like this:
for x,y,z in list1:
print x,y,z
What I would like to get as a result:
Hello World.
I heart python
I know I can do it like this but I would like to know if there is something that doesn't require index counting. Preferably using a for loop.
index=0
while index<len(list1):
print list1[index],list1[index+1],list1[index+2]
index+=3