This language bar is your friend. Select your favorite languages!

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

for x in zip(list[::2], list[1::2]):
    print(x)
import std.range;
list.chunks(2).each!writeln;
import "fmt"
for i := 0; i+1 < len(list); i += 2 {
	fmt.Println(list[i], list[i+1])
}
list.each_slice(2){|slice| p slice}
for pair in list.chunks(2) {
    println!("({}, {})", pair[0], pair[1]);
}

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

Bzzzzzzzzzz

Related idioms