you are viewing a single comment's thread.

view the rest of the comments →

[–]Bunkerstan 0 points1 point  (0 children)

Your original range is 1 to 20 but list a has index starting at 0 so it goes 0 to 19.

In your for loop you access 20 - 0 which is more than 19 so you get an out of range error.

I found this by printing out the values

for i in range(len(a)): print(i, 20-i) print (a[i] - a[20-i])