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

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...