When I execute this code, the "list" argument is changed in the main module, but the the "i". Why? How can I change the "i" argument in the module ?
def func2(list, i):
print (list, i)
list += [4,1]
i += 1
print(list, i)
return
j = 1
l = [0,1]
func2(l, j)
print("---",l , j)
Thanks to @JBernardo for the tip. The real solution is to put the variable in a list. Now I can change both arguments and that is what I wanted.
def func2(list, i):
print (list, i)
list += [4,1]
i[0] = i[0]+1
print(list, i[0])
return
j = [1]
l = [0,1]
func2(l, j)
print("---",l , j[0])