Question: Write a function that receives a tuple as input. The tuple might include duplicates. Convert the tuple to a set which will remove duplicates
Write a function that receives a tuple as input. The tuple might include duplicates. Convert the tuple to a set which will remove duplicates automatically. Then covert the set to a list. Then sort the list. Then create a new list that includes the items in the previous list, each one duplicated as many times as its index. For instance, the first item in the list would appear only once in the new list, the second item in the list would appear two times in the list, etc. Then it prints the new list and returns the new list. For instance, if the input is ('b', 'a', 'c', 'a', 'c'), the output should be ['a', 'b', 'b', 'c', 'c', 'c]. If the input is (8, 5, 6, 6), the output should be [5, 6, 6, 8, 8, 8].
Step by Step Solution
3.49 Rating (152 Votes )
There are 3 Steps involved in it
Code 1 2 m in 670 3 4 Step 12 5 def func1t ssett convert to set 1lists convert to list 1 sort so... View full answer
Get step-by-step solutions from verified subject matter experts
