Code print(rem_duplicate(("Hi",1,2,3,3, 'Hi a', "a',[1,2]))) ('Hi', 1, 2, 3, 'a', [1, 2]) Task 12 Write a python function that takes a list as an argument. Your task is to create a new list where each element can be present at max 2 times. Inside the function, print the number of elements removed from the given list. Finally, return the new list and print the result. Hint: You may use list_name.count(element) to count the total number of times an element is in a list. list_name is your new list for this problem. Function Call: function_name([1, 2, 3, 3, 3, 3, 4, 5, 8, 8]) Output: Removed: 2 [1, 2, 3, 3, 4, 5, 8, 8] Function Call: function_name([10, 10, 15, 15, 20]) Output: Removed: 0 (10, 10, 15, 15, 20] In [8]: def function_name(1): count=0 for i in l:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Downloads/
assum_sec X
+
English
localhost:8888/notebooks/Downloads/21201491_Nuzhat%20Tabassum_sec-17_CSE110_assignment-06.ipynb
C jupyter 21201491_Nuzhat Tabassum_sec-17_CSE110_assignment-06 Last Checkpoint: 8 hours ago (unsaved changes)
Logout
File
Edit
View
Insert
Cell
Kernel
Widgets
Help
Trusted
Python 3 O
+
> Run
Code
print(rem_duplicate(('Hi',1,2,3,3, 'Hi','a','a',[1,2])))
("Hi', 1, 2, 3, 'а', [1, 2])
Task 12
Write a python function that takes a list as an argument. Your task is to create a new list where each element can be present at max 2 times. Inside the
function, print the number of elements removed from the given list. Finally, return the new list and print the result.
========:
=======
Hint: You may use list_name.count(element) to count the total number of times an element is in a list. list_name is your new list for this problem.
Function Call:
function_name([1, 2, 3, 3, 3, 3, 4, 5, 8, 8])
Output:
Removed: 2
[1, 2, 3, 3, 4, 5, 8, 8]
Function Call:
function_name([10, 10, 15, 15, 20])
Output:
Removed: 0
[10, 10, 15, 15, 20]
In [8]:
def function_name(1):
count=0
for i in 1:
if 1.count (i)>2:
1. remove (i)
10:57 PM
12/17/2021
()
Transcribed Image Text:Downloads/ assum_sec X + English localhost:8888/notebooks/Downloads/21201491_Nuzhat%20Tabassum_sec-17_CSE110_assignment-06.ipynb C jupyter 21201491_Nuzhat Tabassum_sec-17_CSE110_assignment-06 Last Checkpoint: 8 hours ago (unsaved changes) Logout File Edit View Insert Cell Kernel Widgets Help Trusted Python 3 O + > Run Code print(rem_duplicate(('Hi',1,2,3,3, 'Hi','a','a',[1,2]))) ("Hi', 1, 2, 3, 'а', [1, 2]) Task 12 Write a python function that takes a list as an argument. Your task is to create a new list where each element can be present at max 2 times. Inside the function, print the number of elements removed from the given list. Finally, return the new list and print the result. ========: ======= Hint: You may use list_name.count(element) to count the total number of times an element is in a list. list_name is your new list for this problem. Function Call: function_name([1, 2, 3, 3, 3, 3, 4, 5, 8, 8]) Output: Removed: 2 [1, 2, 3, 3, 4, 5, 8, 8] Function Call: function_name([10, 10, 15, 15, 20]) Output: Removed: 0 [10, 10, 15, 15, 20] In [8]: def function_name(1): count=0 for i in 1: if 1.count (i)>2: 1. remove (i) 10:57 PM 12/17/2021 ()
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY