Remove duplicates from a tuple
Write a Python program to remove duplicates from a tuple, keeping the order.
(6, 4, 9, 0, 2, 6, 1, 3, 4)
(6, 4, 9, 0, 2, 1, 3)
Approach
tuple(dict.fromkeys(t)).
Solution
print(tuple(dict.fromkeys((6, 4, 9, 0, 2, 6, 1, 3, 4))))(6, 4, 9, 0, 2, 1, 3)
Learn the concept
New to this topic? Read the lesson, then come back.