lt1 = [(1, 1), (1, 1), (1, 5), (1, 4), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2)]
How can I report an error if (1,1) in the above list or some other tuple occurs more than once
Similarly for the list
lt22 = [['a', (1,1)], ['a', (1,2)], ['a', (1,2)], ['a', (1,3)], ['b', (2,1)], ['b', (2,2)], ['b', (2,2)]]
How to report an error if [‘a’, (1,2)] or any other element occurs more than once
Use a set and a loop; the set will let you know if you’ve seen an element before:
Note that for mutable elements such as found in your second list, you want to convert these to non-mutable variants such as tuples first: