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
How is distributed ledger technology (DLT) used in a blockchain?
andrey2020 [161]

Answer:

I believe the answer is D. To keep records of transactions in different places.

Explanation:

3 0
2 years ago
What setting in Word keeps single lines of a new
Gre4nikov [31]

Answer:

C (Window/Orphan control)

Explanation:

An "orphan" in formatting is a single line of text that is left alone/separated from the rest of the paragraph. Orphan control prevents this from happening by keeping lines together.

3 0
3 years ago
What are two examples of ways an electronic record may be distributed to others
lions [1.4K]

Explanation:

Two ways an electronic record may be distributed are e-mail or printing and publishing to others.

6 0
3 years ago
Which of these is the best example of an asset?
ArbitrLikvidat [17]

I believe it's the second answer:

The antique diamond necklace someone is wearing

5 0
3 years ago
PLEASE HELP, NEED THIS TURNED IN IN 20 MINUTES!!!!!! WILL GIVE BRAINLIEST!!!
ratelena [41]

Answer:

We cant help with that. Maybe give me more information?

5 0
3 years ago
Other questions:
  • Modern database tools support ________________, which entails separating data from the programs that manipulate data.
    14·1 answer
  • Which writing format is also beneficial to public speaking? a. Five paragraph essay c. Conventions b. Prose d. None of these
    5·2 answers
  • In order to plan George’s birthday, his father gave him a list of people who attended his birthday for the last five years. What
    8·2 answers
  • on average, someone with a bachelor’s degree is estimated to earn _______ times more than someone with a high school diploma
    13·1 answer
  • The___provides access to the internet; may also be internal
    11·1 answer
  • What will the following segment of code output?
    7·1 answer
  • Your computer is taking longer than usual to open files and you notice that your hard drive light stays on longer than usual whi
    9·1 answer
  • Analog computers are general purpose computers : true ? or false ?​
    8·1 answer
  • व्याख्या c) Differentiate between Raster Image and Vector Image.​
    6·1 answer
  • Differentiate between patent and copyright.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!