Skip to content

Latest commit

 

History

History
35 lines (21 loc) · 440 Bytes

File metadata and controls

35 lines (21 loc) · 440 Bytes

UnboundLocalError: local variable referenced before assignment

Reproduce

count = 10

def update():
    count = count + 1

update()

Error Message

UnboundLocalError: local variable 'count' referenced before assignment

Fix

count = 10

def update():
    global count
    count = count + 1

update()
print(count)

Reflection

I tried to update a variable inside a function without declaring it.