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
Vladimir79 [104]
3 years ago
6

The aim of this activity is to implement an algorithm that returns the union of elements in a collection. Although working with

sets is quick and easy in Python, sometimes we might want to find the union between two lists. Create a function called unite_lists, which uses a loop to go through both lists and return common elements. Do not use the built-in set function.
Computers and Technology
1 answer:
shusha [124]3 years ago
3 0

Answer:

The function in Python is as follows:

def unite_lists(A, B):

   union = []

   for elem in A:

       if elem in B:

           union.append(elem)

   return union

Explanation:

This defines the function

def unite_lists(A, B):

This initializes an empty list for the union list

   union = []

This iterates through list A

   for elem in A:

This checks if the item in list A is in list B

       if elem in B:

If it is present, the item is appended to the union list

           union.append(elem)

This returns the union of the two lists

   return union

You might be interested in
How do you set up nordvpn with spectrum?
Setler [38]

Answer:

simple

Explanation:

use nordvpn with discount code: Chonchode

7 0
3 years ago
Which of the following could have a negative impact a planned route?
Nata [24]

Answer:

B

Explanation:

8 0
3 years ago
MTINGAENL ....
erik [133]

Answer:

Alignment

Explanation:

7 0
3 years ago
What is an Array? 20 POINTS!!!
EastWind [94]

Answer:

I'm about 99% sure it's C: a unique address or location un the collection

6 0
2 years ago
An input value has to be greater than 18 and less than 65 if a driving license is to be approved for issue. What type of input c
katrin2010 [14]

Answer:

You should use an "if" statement to check whether the number is greater than 18 or less than 65.

Explanation:

You usually use "if" statements whenever you want to compare a number to another. Keep in mind that "if" statements are not only used for comparison!

4 0
3 years ago
Other questions:
  • As a final lesson to her team, Katie shows them a job that has already been preflighted and is now getting ready to be sent to t
    7·1 answer
  • A computer hard disk starts from rest, then speeds up with an angular acceleration of 190 rad/s2 until it reaches its final angu
    10·2 answers
  • Describe the conceptual design.
    8·2 answers
  • HURRY
    5·1 answer
  • Samantha has to create a video for her science project on the blossoming of a flower from a bud to one with fully opened petals.
    5·2 answers
  • What command prompts should be used to assign an IP address to:
    9·1 answer
  • What is TLB for? Why TLB? Given the following number, what is theeffective memory access time?
    11·1 answer
  • A byte contains how many bits? Question 3 options:
    13·2 answers
  • My pc suddenly freezes and i can't open any apps or task manager. Apps do not open at all and if i restart from the start it get
    9·1 answer
  • What are good reasons to do yearly disaster recovery testing? check all that apply
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!