'How do I print every element after the first, twice?
The usage case would be for dates.... for example:
Monday, Tuesday
Tuesday, Wednesday
Wednesday, Thursday
Thursday, Friday.
Or using numerics:
0, 1
1, 2
2, 3
3, 4
4, 5
5, 6
If I have a list of numbers like
numbers = [0, 1, 2, 3, 4, 5, 6], I've tried:
for x, y in zip(numbers[::2], numbers[1::2]):
print(x, y)
But this doesn't work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
