note: a[-1] refers to the last element of the list.
you assign to a[index] in every loop iteration over a
for a[index] in a:
a[index] will be assigned the values a[0], a[1], ..., a[-1] during the loop and end up being assigned to
a[index] = a[-1]
usually you try not to mess with the list you are iterating over:
for item in a:
# do something with item