In this python tuple program, we will count the total number of unique tuples in a list.
Steps to solve the program
- Take a list of tuples as input.
- Create a set of the given list to remove duplicate tuples using set().
- Now count the total number of unique tuples using len().
- Print the output.
l =[(8,9),(4,7),(3,6),(8,9)]
print("Original list of tuples: ",l)
print("Total number of unique tuples: ",len(set(l)))
Output :
Original list of tuples: [(8, 9), (4, 7), (3, 6), (8, 9)]
Total number of unique tuples: 3