Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions

Question

Stages of a Relationship?

Answered: 1 week ago