I have a list of tuples that starts out empty and is appended with new user-generated tuples.
if left_mouse == True:
generic_list.append((mouse_position_x, mouse_position_y))
To prevent having multiple tuples with the same (x, y) data, I want to iterate through the list and check if the newest tuple is the same as any other tuple in the list, and if it is, replace the old tuple with the new one.
for tuple in tuple_list:
if tuple_list[-1].position == tuple_list[i].position:
tuple_list.remove(i)
I know what I've got is wrong, but I don't know why or how to move forward. Any help would be really appreciated.
Edit: I'm now using set() and it works perfectly. Thanks everyone.