Q:

Python For Loop using List - Trying to group number pairs based on last number used in loop

Starting with list:
l = [0,1,2,3,6,7,8,9]

Trying to produce:
nl [[0, 1], [1, 2], [2, 3], [6, 7], [7, 8], [8, 9]]

Using a for loop, I was trying to iterate through the list, and use the previous number as my comparison to create a cluster group, with overlapping groups using numbers multiple times. It's not working, and I'm not sure why. It stops adding to the list once it gets to the 6.
*Edit: Yes, only grouping number sequence pairs, 1,2,3,etc. and skip 3,6
Test Code:
l = [0,1,2,3,6,7,8,9]
nl = []
lastN = 0

for i in range(1,len(l)):
    lastN = l[i - 1]

    if i - lastN == 1:
        nl.append([lastN, i])

    print('nl',nl)

This results in:
nl [[0, 1], [1, 2], [2, 3], [3, 4]]

My goal was:
nl [[0, 1], [1, 2], [2, 3], [6, 7], [7, 8], [8, 9]]

A:

Try this: 
https://repl.it/repls/SelfreliantNaturalDaemon
l = [0,1,2,3,6,7,8,9]
nl = []

for i in range(len(l)-1):
    if l[i+1] - l[i] == 1:
      nl.append([l[i], l[i+1]])

print('nl',nl)

Returns:
nl [[0, 1], [1, 2], [2, 3], [6, 7], [7, 8], [8, 9]]

