x = 10
def func():
global x
x += 1
print(x)
func()
지역변수 영역인 func(): 에서 x가 global임을 명시하지 않으면 발생하는 에러
출처: korbillgates.tistory.com/98
[파이썬] 파이썬 에러 UnboundLocalError: local variable referenced before assignment
안녕하세요 한주현입니다. 오늘은 파이썬에서 흔히 볼 수 있는 오류인, UnboundLocalError: local variable referenced before assignment 에 대하여 알아보겠습니다. 문제 상황 UnboundLocalError: local vari..
korbillgates.tistory.com
댓글