1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yan [13]
3 years ago
9

Write a function named remove_duplicates that takes a list (of numeric and/or string values) and returns a new list with only th

e unique elements from the original. This function assumes that there is at least 1 element in the list and that the list does not contain any sublists. The original list is not modified in any way. The returned list does not have to preserve the order of the original list.
Computers and Technology
1 answer:
Lorico [155]3 years ago
6 0

Answer:

def remove_duplicates(lst):

   no_duplicate = []

   dup = []

   for x in lst:

       if x not in no_duplicate:

           no_duplicate.append(x)

       else:

           dup.append(x)

   for y in dup:

       if y in no_duplicate:

           no_duplicate.remove(y)

   return no_duplicate

Explanation:

Create a function called remove_duplicates that takes one parameter, lst

Create two lists one for no duplicate elements and one for duplicate elements

Create for loop that iterates through the lst. If an element is reached for first time, put it to the no_duplicate. If it is reached more than once, put it to the dup.

When the first loop is done, create another for loop that iterates through the dup. If one element in no_duplicate is in the dup, that means it is a duplicate, remove that element from the no_duplicate.

When the second loop is done, return the no_duplicate

You might be interested in
Are Microsoft an Apple more secure from malicious action because of their closed-source approach?
omeli [17]

Yes Microsoft and Apple used the closed-source approach to better secure from malware and make to make their operating systems more user friendly.

7 0
3 years ago
___________ are the constant values that are used in a program. ​
77julia77 [94]

Answer: Data

Explanation:

3 0
3 years ago
All air transportation carriers transport freight to some extent. True False
SCORPION-xisa [38]
TRUE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4 0
3 years ago
Read 2 more answers
Which term refers to the technical structure of the software, how users interact with the software, and how the software is phys
mars1129 [50]
The Answer is <span> Architecture</span>
7 0
3 years ago
What project started the development of inter-network connections using tcp/ip that has evolved into the internet today.?
rosijanka [135]
Dial Up, help start it
3 0
3 years ago
Other questions:
  • Assume that to_the_power_of is a function that expects two integer parameters and returns the value of the first parameter raise
    13·1 answer
  • The component that allows you to make a paper-based copy of a body of text is the _____.
    12·1 answer
  • What are features of a product?
    8·2 answers
  • Which statement best describes the cut and paste option in a word processor?
    6·2 answers
  • How many pounds must a sand bag weigh to test if a safety net can absorb the proper amount of force? A. 150 lbs. B. 200 lbs. C.
    6·1 answer
  • What decides the amount of delay between shots on a digital camera?
    7·1 answer
  • List five kinds of view in the computer and briefly define each​
    9·1 answer
  • Please helpppppppppppppp
    11·1 answer
  • Just a quick question, how do you set something == to char and int in an if statement (java)
    10·1 answer
  • Can someone help me debug this please
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!