Answer :
The function that replaces the values in an array is as follows:
def replace_elem(a, integer1, integer2):
for i in range(len(a)):
if a[i] == integer1:
a[i] = integer2
return a
print(replace_elem([7, 4, 10, 3, 7, 2, 4, 5], 4, 6))
Code explanation.
The code is written in python.
- We defined a function named "replace_elem". The function accepts an array a, and integers integer1 and integer2.
- Then, we used a loop to loop the index of the array.
- If any of the index value is equals to the integer1, we replace it with integer2.
- Then return the new values of the array a.
- Finally, we call the function with its parameters.
learn more on function here: https://brainly.com/question/15691123
