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
Freeeeeeee brainliest!!!
kondaur [170]

Answer:

Oh Thanks :)

Explanation:

7 0
3 years ago
QUESTION 11
tino4ka555 [31]

Answer:

x == 32

Explanation:

CODE in Java:

       int x = 32;

       if(x == 32){

           System.out.println("Pass");

       }

       else{

           System.out.println("Fail");

       }

OUTPUT:

Pass

8 0
2 years ago
A programmer writes a for statement to count from 1 to 10 and explicitly mentions the 1 and the 10 in the for “header.” which re
o-na [289]
The relational operator used would probably be <=
6 0
3 years ago
What does the action tool allow you to do in Microsoft Powerpoint?
12345 [234]

B.  Add actions , such as fly ins , between slide


8 0
3 years ago
Discuss one simple example of hybrid computer.​
andrezito [222]

Answer:

thermometer , petrol pump

5 0
3 years ago
Other questions:
  • Vannevar bush imagined a desktop computing machine that would allow people to access data stored in various information centers
    10·1 answer
  • A user states that when they power on their computer, they receive a "Non-bootable drive" error. The user works with external st
    8·1 answer
  • Janice, who is 15, posts a picture of herself drinking alcohol and making an obscene gesture on her social networking page. Whic
    11·2 answers
  • A public Wi-Fi risk that can be minimized by only visiting
    5·1 answer
  • ___________________ are aggregated collections of memory and cpu resources that can be shared among groups of virtual machines o
    11·1 answer
  • Can anyone please help me to solve this question?
    10·1 answer
  • Which logic correctly describes an algorithm to find the smallest of the three numbers a, b, and c and store the smallest number
    15·1 answer
  • What is the best programing language to use for building video games?
    10·1 answer
  • DEFINE Problem:
    11·1 answer
  • What name is given to any changes to the original data such as users manually modifying data, programs processing and changing d
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!