This happens because a return
is always going to be the end of a function.
You can have infinites return
, the first one that touches your function will be terminated and will return the object that the return is pointing to.
Example:
Function that prints a list.
In both cases they will receive as input:
[1,2,3,4]
Below are two cases, the latter being what you are using.
def printar(n):
for x in n:
print(x)
This would be a perfect skeleton for your code. The result would be:
1
2
3
4
However, what you are trying to do is:
def printar(n):
for x in n:
return(x)
That the result would be:
1