I would use the method all() Python doing a for in tuples.
Example:
a = [([1, 2], [1, 2]), ([1, 2], [4, 5])] # primeira lista igual
b = [([1, 2], [1, 2]), ([1, 3], [4, 5])] # primeira lista diferente
c = [([1, 2], [2, 2]), ([1, 2], [4, 5]), ([1, 2], [4, 2]), ([1, 2], [1, 6]), ([1, 2], [6, 3])]
d = [([1, 2, 3, 4], [2, 2]), ([1, 2, 3, 4], [4, 5]), ([1, 2, 3, 4], [4, 2]), ([1, 2, 3, 4], [1, 6]), ([1, 2, 3, 4], [6, 3])]
all([y == x[0] for y in [x[0] for x in a]])
True
all([y == x[0] for y in [x[0] for x in b]])
False
all([y == x[0] for y in [x[0] for x in c]])
True
all([y == x[0] for y in [x[0] for x in d]])
True
what if the list has more tuples?? because the number of tuples is undetermined..
– CSAnimor
@Stinrose doesn’t matter how many items are on the first list, or how many lists are on the tuple. The answer is updated with more examples.
– Vitor Leal
but in this case I will not have 2 lists to compare whether they are different or not... I in the code have a function in which I ask for this list, and I need to test if what they have given me is in accordance with the request... in this case it has to have the first list of each always equal
– CSAnimor
This is exactly what this code does. It takes all the first lists of tuples and checks if they are equal. If any is not equal it returns False
– Vitor Leal
ah, you’re right! thank you!
– CSAnimor