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 

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

1 Expert Approved Answer
Step: 1 Unlock

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

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!