Conceptually, I want to do:
arr[20:] = 0
where arr is a list. How can I do this?
arr
list
You can do it directly using slice assignment.
arr[20:] = [0] * (len(arr) - 20)
But the natural way is just to iterate.
for i in xrange(20, len(arr)): arr[i] = 0