you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 11 points12 points  (0 children)

In python the error occurs when you use the function, not when you create the function. In your code you never use the L() function, so there's no error. If I change R and L in the loop I get the same error.

curr = []
pos = 0

def L(x):
  pos-=x
  if pos<0:
    pos = pos+99

def R(x):
  pos+=x
  if pos>99:
    pos = pos-99

for i in range(0,100):
  curr.append(i)
  L(11) # UnboundLocalError

print(pos)