When return i
happens for the first time in your function, the function stops and returns the current i
.
def multAll(A, k):
return_value = []
for i in A:
i = i*k
return_value.append(i)
return return_value
Like this, a complete list return_value
is created, and that list is returned.