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

python 3please  python 3please Question 2: Remove Repeating elements (4 points) Write a

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 renove repeat ( (2,2,2, .sack.. ,David ,, s, uaek. n remove-repeat ( tpl, n) 2). 2)-.bavid. , S) 1 def renove_repeat(tpi, n) '-> 2 tenp-1st[tp1]/Converting tuple to ist templ- for i in temps if (temp.count(i)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!