Write a function called ​replace_elem​ that takes an array and two values and uses the simple search algorithm to replace all instances of the first value with the second value.

I NEED THIS SOON

Respuesta :

The replace_elem program is an illustration of functions, whose execution is carried out when the function name is evoked or called.

The main program

The program written in Python, where comments are used to explain each action is as follows:

#This defines the function

def replace_elem(myList, a, b):

   #This iterates through the list elements

   for i in range(0,len(myList)):

       #The following if condition replaces the element

       if(myList[i] == a):

           myList[i] = b

   #This prints the new list elements

   print(myList)

Read more about python programs at:

https://brainly.com/question/26497128

ACCESS MORE