I want to assign value to function of below code:
def adds(y):
for i in y:
z = i + 1
print(z)
x = [1, 2, 3]
adds(x)
output:
2
3
4
But when i tried to assigned the result to function with creating instance such:
# print(z) commented
p = adds(x)
print(p)
output:
None
expected output:
2
3
4
gives the return inside for loop gives output: 2
gives the return inside function block or set variable z to global inside the for loop block, and recall it in the outside gives same output: 4
How do to achieve the expected output: 2 3 4, from the return value to function of above code
returnanything, that's why you getNone.