Help! UnboundLocalError: local variable 'B' referenced before assignment. Thanks!

``````            if a >= 3:
A = (3 ^(int(log((a/3), 2)* 3)))
if b >= 3:
B = (3 ^(int(log((b/3), 2)* 3)))
if c >= 3:
C = (3 ^(int(log((c/3), 2)* 3)))
if d >= 3:
D = (3 ^(int(log((d/3), 2)* 3)))
if e >= 3:
E = (3 ^(int(log((e/3), 2)* 3)))
if f >= 3:
F = (3 ^(int(log((f/3), 2)* 3)))
if g >= 3:
G = (3 ^(int(log((g/3), 2)* 3)))
if h >= 3:
H = (3 ^(int(log((h/3), 2)* 3)))
if i >= 3:
I = (3 ^(int(log((i/3), 2)* 3)))
if j >= 3:
J = (3 ^(int(log((j/3), 2)* 3)))

puntaje  = str(int(A + B + C + D + E + F + G + H + I + J + K + L))
``````

If that's all your code, you never give a value to any of your lower-case variables.

Initialize your variables A to L this way:
`A = B = C = D = E = F = G = H = I = J = K = L = 0`
before you reach your if statements.

``````puntaje  = str(int(A + B + C + D + E + F + G + H + I + J + K + L))
``````

If "B", or any variable is less than 3, then the if statement is not satisfied and B (or any variable) is never declared. Some refactored code

``````puntaje = 0
for var in [a, b, c, d, e, f, g, h, i, j]:
if var >= 3:
puntaje + = 3 ^(int(log((var/3), 2)* 3))
print puntaje
``````