get next element while looping

Solutions on MaxInterview for get next element while looping by the best coders in the world

showing results for - "get next element while looping"
Pedro
21 Oct 2019
1arr = [1,2,3,4]
2arr = iter(arr)
3
4for x in arr:
5  print(x, next(arr))