In this python tuple program, we will remove duplicates from a tuple.
Steps to solve the program
- Take a tuple as input.
- Use set() on the tuple to remove duplicates from it.
- After using the set() convert the outcome to a tuple using tuple().
- Print the output.
tup = (6,4,9,0,2,6,1,3,4)
print("Original tuple: ",tup)
new_tup = tuple(set(tup))
print("New tuple: ",new_tup)
Output :
Original tuple: (6, 4, 9, 0, 2, 6, 1, 3, 4)
New tuple: (0, 1, 2, 3, 4, 6, 9)