Friday, 30 March 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

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...