0

I've been wondering if I can make this code more pythonic

for i in xrange(len(my_list) - 1)):
    first = my_list[i]
    second = my_list[i + 1]

something like:

for first,second in foo(my_list):

In Scala I would use (my_list.tail, my_list).zipped

I'm looking for a solution that will NOT allocate extra memory like zip(my_list,my_list[1:])

Lukasz Madon
  • 14,664
  • 14
  • 64
  • 108

0 Answers0