I'm a novice coding learner. I am trying to extract numbers only in sequential from the list.
for example, my list is:
s = [2, 4, 6, 7, 8, 9, 10, 13, 14, 15]
from this list I want only the numbers in sequential:
6,7,8,9,10, 13,14,15
so, I have the following code, but it doesn't work.
s = [2, 4, 6, 7, 8, 9, 10, 13, 14, 15]
for i in s:
if s[i+1] - s[i] == 1:
print(s[i])
could you give me some idea? Thank you.