Friday, March 30, 2018

python - what does n += 2 in this def?







I have a def function looks like:



def s(xs, n, m):
t = []

while n < m:
t.append(xs[n])
n += 2
return t


I understand the above code by t.append(xs[n]), but have no idea what n += 2 means here.



Any help will be appreciated.
Thanks

No comments:

Post a Comment