Write a function called rem_duplicate that takes a tuple in the parameter and return a tuple removing all the duplicate values. Then print the returned tuple in the function call. ===================================================== Hints: Unlike lists, tuples are immutable so, the tuple taken as an argument cannot be modified. But list can be modified and lastly for returning the result use type conversion. You need to use membership operators (in, not in) for preventing adding any duplicates values. ===================================================== Example1: Function Call: rem_duplicate((1,1,1,2,3,4,5,6,6,6,6,4,0,0,0)) Output: (1, 2, 3, 4, 5, 6, 0) ==================================== Example2: Function Call: rem_duplicate(("Hi", 1, 2, 3, 3, "Hi",'a', 'a', [1,2])) Output: ('Hi', 1, 2, 3, 'a', [1, 2])
Write a function called rem_duplicate that takes a tuple in the parameter and return a tuple removing all the duplicate values. Then print the returned tuple in the function call.
=====================================================
Hints:
Unlike lists, tuples are immutable so, the tuple taken as an argument cannot be modified. But list can be modified and lastly for returning the result use type conversion. You need to use membership operators (in, not in) for preventing adding any duplicates values.
=====================================================
Example1:
Function Call:
rem_duplicate((1,1,1,2,3,4,5,6,6,6,6,4,0,0,0))
Output:
(1, 2, 3, 4, 5, 6, 0)
====================================
Example2:
Function Call:
rem_duplicate(("Hi", 1, 2, 3, 3, "Hi",'a', 'a', [1,2]))
Output:
('Hi', 1, 2, 3, 'a', [1, 2])
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images