IMMEDIATE PROBLEM
What does this mean?
i+1[0]
i is the tuple; you are trying to use i as an index and an element. The iteration you need is more like:
for i in range (len(tuples2)): if tuples2[i] == tuples2[i+1]:
... who is still not doing this job. This checks the equality of the entire tuple. However, you say that all you care about is the equality of the first element. Then you need to:
if tuples2[i][0] == tuples2[i+1][0]:
This is in terms of your current code; others have shown you more βpythonicβ ways to do this.
COMMON DECISION
This code assumes that the other elements of the tuple are equal, with tuples with the same first elements adjacent in the list, and that matching tuples fall only in pairs. Is it possible that your list will include the following:
tuples2 = [(3, 'A', 'C'), (3, 'C', 'A'), (2, 'B', 'C'), (2, 'C', 'B'), (1, 'A', 'B'), (1, 'A', 'Z'), (1, 'B', 'A')]
With an additional βZβ element, possibly buried between the β3β elements? Despite this, even if you sort the list, you get the "AZ" element between the other "1" elements.
If this is a problem for you, I suggest converting each tuple to a list first, sorting the elements in order. For example, you had to convert (1, 'B', 'A') to [1, 'A', 'B']. Then use any of these methods to eliminate duplicates, including the one you have already programmed. I usually do this by turning things back into tuples and then forming a set that automatically removes duplicates.