I wanted to change the value of the argument(list), so I wrote the code as follows, but it didn't work properly.
def add1(s): # s is a list
for i in s:
i += 1
So I changed the code as shown below, and it worked. However, I want to know why the first code didn't work properly.
def add1(s):
for i in range(len(s)):
s[i] += 1
If you know the reason and explain it, I would really appreciate it.