The function do_math() is supposed to iterate over the lists numbers and operations. Each operations element is defined in do_math and is supposed to be applied to the corresponding numbers element. The loop however runs only once and then stops. Any ideas?
from math import sqrt
def do_math(numbers, operations):
for i, j in list(zip(numbers, operations)):
if j == "Root":
return sqrt(i)
elif j == "Square":
return i**2
elif j == "Nothing":
return i
numbers = [2, 9, 25, 6, -3]
operations = ["Square", "Root", "Square", "Root", "Nothing"]
print(do_math(numbers, operations))