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]
2 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]2 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 program that initializes a string variable and prints the first three characters, followed by three periods, and then th
d1i1m1o1n [39]

firstly we have to initialize the variable, means to give variable a value and then print the statement

string = "fahadisahadam"

print(string[:3]+"..."+string[-3:])

string is a data type that contains two or more characters.

means the string is fahadisahadam so the print will print first three characters. follow by three periods(...) and then last three characters.

The output will be:

fah...dam

8 0
3 years ago
IN PYTHON LANGUAGE
shtirl [24]

favorite_color = input("Enter favorite color:\n")

pet = input("Enter pet's name:\n")

num = input("Enter a number:\n")

print("You entered: "+favorite_color+" "+pet+" "+num)

password1 = favorite_color+"_"+pet

password2 = num+favorite_color+num

print("First password: "+password1)

print("Second password: "+password2)

print("Number of characters in "+password1+": "+str(len(password1)))

print("Number of characters in "+password2+": "+str(len(password2)))

This works for me.

8 0
2 years ago
Read 2 more answers
Which of the following statements about meta tags is TRUE?
Iteru [2.4K]

Answer:

I guess c no. is the answer

6 0
2 years ago
Read 2 more answers
You are researching RAM for a computer you are building for a friend who will be using the system as a home office server for he
AlexFokin [52]

Answer:

ECC memory

Explanation:

According to my research on information technology, I can say that based on the information provided within the question the best type of RAM for this situation would be ECC memory (RAM). This abbreviation refers to Error-Correcting-Code, this memory can detect and correct many common types of errors, and is used mainly for servers or when sensitive data is involved where errors and data corruption cannot be allowed to happen under any circumstance.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

3 0
3 years ago
PLZ HELP ME!!
katen-ka-za [31]

Customer experience means different things to different companies, and objectives must be clearly defined at the corporate level to maintain consistency.

6 0
3 years ago
Other questions:
  • Nancy would like to configure an automatic response for all emails received while she is out of the office tomorrow, during busi
    13·2 answers
  • What can be done to improve the security of business uses of the Internet? Give several examples of ecurity measures and technol
    9·1 answer
  • While reviewing the Quick Access toolbar, Sarah notices that the Redo button is not there. This is because the Redo button only
    12·1 answer
  • What is a geam in the ggplot2 system?
    5·1 answer
  • What will result if the following code is used in an HTML file? New Title
    13·2 answers
  • Explain software piracy and Hacking​
    13·2 answers
  • The ratio of boys and girls is 4:5 calculate the number of boys if the are 1080 learners in schools​
    11·1 answer
  • PA theme is a major message that a writer convoys through a text. you have explored many themes in the hobbit one theme in the n
    5·1 answer
  • You're doing desktop support and the company policy is that you can only help with company equipment. A user walks in:
    6·1 answer
  • The three main objectives of information security are
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!