Add an offset to part of a list in Python?
I have a list a = [1, 2, 3, 4, 5], and now I wish to add a 1 to every
element from index 2 onwards, i.e. a[2] + 1, a[3] + 1, a[4] + 1.
That is I want a = [1, 2, 4, 5, 6] in the end.
What is the most Pythonic way of dong so?
No comments:
Post a Comment