I need some help in determining how to get the relevant numbers inside a list of tuples. I cannot figure out how to structure the nested statements to get the required results.
To explain it better:
I have a list of tuples as follows and they are all ready sorted smallest value to largest value:
my_list = [(1,2,3,4,5),(1,2,3,4,6),(1,2,3,4,7),(2,3,4,5,6),(2,3,4,5,7)]
So I need to iterate through each value inside each tuple and print the tuple if the values inside the tuple follows the previous number in the same tuple.
So the list that should be printed is [(1,2,3,4,5),(2,3,4,5,6)] as the numbers follow on each other where as the rest of the values in the other tuples jump a number from time to time. I will be assigning the new_list of numbers following each other in a new list and removing those numbers from a another list I have.
So the code I think should be as follows if someone can possibly shed some light on my problem or possibly make any suggestions:
new_list = []
for a in my_list: #iterate through the lists
if i in a == ??(i-1) #iterate through each value in the list and check it against the number before it excluding the first iteration of i which will have no number before it.
print(list if the numbers follow on each other)
new_list.append(a)