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
Write a C program to perform simple C arithmetic calculations. The user is to enter a simple expression (integer operator intege
Ilya [14]

Answer:

Input example:

select the funcion: 1                                                                                                                  

write the 1sd number2                                                                                                                  

write the 2nd number1                                                                                                                  

value is 2.000000                                                                                                                      

Explanation:

#include <stdio.h>

main()

{

//define the variables as float

float a, b, c, e;

char d;

while (1)  

{      

//input values

printf("select the function: ");

scanf("%c",&d);

printf("write the 1sd number");

scanf("%f",&a);

getchar();

printf("write the 2nd number");

scanf("%f",&b);

getchar();

if (d=='%')

{

    a=a*b/100;

}

if (d=='*')

{

    a=a*b;

}

if (d=='+')

{

    a=a+b;

}

if (d=='/')

{

    a=a/b;

}

if (d=='-')

{

    a=a-b;

}

printf("value is %f \n",a);

}

printf("final value is %f",a);

getchar();

}

8 0
4 years ago
Can java scanner not take in a negative input?
algol [13]

Answer:

It can take a negative input

Explanation:

When you declare a variable in Java and you get your input via Scanner library; the Scanner library will accept the input irrespective of whether it's negative or not.

Take for instance, the following segment

<em>Scanner input = new Scanner(System.in);</em>

<em>int userinput = input.nextInt()</em>

<em />

Irrespective of whether userinput is negative or positive, it'll accept it.

8 0
3 years ago
When the atmosphere has too much carbon dioxide in it, the oceans absorb some of it to achieve a new balance. This is an example
horsena [70]
The answer is B. 
A geochemical cycle. 
8 0
4 years ago
Read 2 more answers
Which can be used to enter and manipulate information in a database?<br><br> ANSWER: C) a form
alexgriva [62]

Answer:

a form

Explanation:

it says the answer already in the question

3 0
4 years ago
HELP
Aleks [24]

Answer:

If a good friend comes to me for advice in pursuing a music career. With my knowledge of digital technology and the performing

arts, my advice to use digital technology to help build her career by <u>Delivering service to clients .</u>

Explanation:

<u>There were several reasons for this: </u>

• Being able to access work platforms and resources removed the need to travel back

to office bases because remote access allowed the completion of administrative

tasks where the practitioner was working.

• Working with clients in rural and isolated areas can prove difficult in terms of meeting

clients face to face and digital solutions helped to resolve this. This is because more

clients can be seen remotely than when practitioners must travel to see them.  

8 0
3 years ago
Other questions:
  • Create a string called alphabet containing 'abcdefghijklmnopqrstuvwxyz', then perform the following separate slice operations to
    14·1 answer
  • When you use the Filter feature, what appears in each column label
    11·1 answer
  • Which country began expanding its borders with exploration in the late 16th<br>century?​
    15·1 answer
  • Writing the E-mail:
    5·1 answer
  • Which of the following networks had these two goals: a) allowing scientists to work together on scientific projects; and, b) fun
    8·2 answers
  • Create a Python program that computes the cost of carpeting a room. Your program should prompt the user for the width and length
    10·1 answer
  • When creating a storyboard, in which section do you mention how you move from one shot to the next?
    8·1 answer
  • Which of the following is/are used in multimedia?
    14·1 answer
  • What is the objective of Accenture‘s e-stewards program
    5·1 answer
  • Order the numbers (1.1)2, (1.4)10, and (1.5)16 from smallest to largest
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!