This question is an exact duplicate of:
for i, e in enumerate(l1):
if (e[0] == e[1]) and ((e[0], e[1]) not in l1):
raise ValueError, '%s is missing' %(e[0], e[1])
if i!=len(l1)-1:
if e[0]==l1[i+1][0] and e[1]!=l1[i+1][1]-1:
raise ValueError, '(%s,%s) is missing ' %(e[0], e[1]+1)
l1 = [(1, 2), (1, 3), (1, 4), (2, 1), (2, 3)]
I am able to work for missing (1,2) and (2,2) but in the above case first it should look for (1,1) to report an error if it's not there however in the above code it goes undetected. Likewise it should traverse the whole list to check if any thing is missing. also what if I want (2,4) and its missing in l1. There should be a error been reported here as well
In general terms:
EDIT
To check if a sequence is out of order:
output:
I'm ignoring your other question as you would simply need to check whether the front letters are the same.
EDIT: Apparently I missed some. New solution that is horribly inefficient and kind of ugly: