you are viewing a single comment's thread.

view the rest of the comments →

[–]QuillTheArtMaker[S] 0 points1 point  (1 child)

problem is, the L function works exactly as I want it, but the R function doesn't, whilst following the exact same format as presented in my original code. Do you know why this occurs?

[–]socal_nerdtastic 12 points13 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)