v=[1,2,3,11,5,8,9,10,11,6,4] in the list above 1,2,3 are consecutive numbers (1st consecutive set). 8,9,10,11 are consecutive numbers (2nd set,largest one). How can I find this 2nd set? This code below gives the consecutive numbers:
for i in range(len(v)-1):
if v[i+1]==v[i]+1:
if v[i-1]!=v[i]-1:
print(v[i])
print(v[i]+1)
Output:1,2,3,8,9,10,11
I was thinking of using something like below and add the outputs in a new list and then find out max value of the list.I can't think of a logic to combining those 2 ideas.
for i in range(len(v)-1):
for j in range(i+1,len(v)):
if v[j]-v[i]
I looked at this example but I think that solution is different from what I am looking for. Thanks in advance for your time and suggestion.