How to deal with the certain pattern of tuples
<p>if </p>

<pre><code>list_1 = [(1, 1), (1, 3), (1, 4), (2, 2), (2, 3)]
</code></pre>

<p>Consider an element of the tuple as (i, j) Now we know if we know that if we know that if (1, 3) exists then (1,1) and (1,2) should exists if any one of it is missing an error is reported. The error detection should be done one by one first for (1,1) then for (1, 2). similarly if we know that for another sequence if (2,3) exists then similarly (2,1) and (2, 2) would exists.</p>

<p>also this is an example list. The example could also be like:</p>

<p>list_1 = [(1, 3), (1, 4), (2, 2), (2, 3), (3,1) (3,4)]  now in this case if (3, 4) exists then (3,1),(3,2) and (3,3) should exists. This pattern can be determined by the max of jth element of each 'i' My code is as gi</p>

<pre><code>for i, e in enumerate(list_1):
              i1 = (1,1)
              if i1 not in list_1:
                 raise ValueError, '%s is missing in %s' %(i1, production)

              if (e[0] == e[1]) and ((e[0],e[1]) not in list_1):
                 #if i1 not in list_1:
                 raise ValueError, '%s is missing in %s' %((e[0], e[1]), production)

              print e, e[0], e[1], (e[0], e[1])
              if i!=len(list_1)-1:


                 if e[0]==list_1[i+1][0] and e[1]!=list_1[i+1][1]-1:

                    raise ValueError, '(%s,%s) is missing in %s ' %(e[0], e[1]+1, production)
</code></pre>
