This code:
def reverse(x):
for i in range(len(x)):
y[i] = x[-(i+1)]
return y
a = [1, 2, 3, 4, 5]
b = reverse(a)
returns a "global variable 'y' not defined" error. WHAT GLOBAL VARIABLE?????
If I add 'y = []' anywhere in the code, either inside the function or outside it, I don't get a global variable error, but I get an 'index value out of range' error instead. What's going on?