Question: python 3please Question 2: Remove Repeating elements (4 points) Write a python function called remove_repeat (tpl,n) which takes a tuple tpl and a number n
Question 2: Remove Repeating elements (4 points) Write a python function called remove_repeat (tpl,n) which takes a tuple tpl and a number n as input. The function returns a copy of the input tuple with all elements in the tuple that appeared at least n times removed. The elements in the returned tuple should follow the same ordering as the input tuple. For example, if tpl (2,2,2, Jack', David', 3, , Jack, 2) and n2, then the resut tuple shoud be ('David'3 5) 1 def remove repeat(tpl, n) temp-list[tplj Converting tuple to list templ-t for i in temp: if (temp.count (i)en): tempi . append ( i ) else: while(temp.coun()1-O) temp.remove(i) return(templ) # Your code here [42]: remove-repeat ( (2,2,2,' ack', "David', 3. 5. 'Jack', 2), 2)-(David .. 3.5) Traceback (most recent call last) TypeError cipython-input-42-710dsaccbosf> in
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
