대충 위 코드들 따라 쳐봤는데 UnboundLocalError가 뜸
Traceback (most recent call last):
File "Desktop\Code\a.py", line 35, in <module>
enchant_i()
File "Desktop\Code\a.py", line 16, in enchant_i
if enchant_num < percent:
^^^^^^^
UnboundLocalError: cannot access local variable 'percent' where it is not associated with a value
아래 UnboundLocalError~ 부분 검색하면 이런 Stackoverflow 글 발견
https://stackoverflow.com/questions/74412503/cannot-access-local-variable-a-where-it-is-not-associated-with-a-value-but
위에서 추정한대로 스코프 문제로 없는 지역 변수를 찾을려고 해서 에러가 발생한듯. 위 글대로 함수 안에서 global percent 같이 전역 변수 사용한다고 명시하는 방법이 있을듯
대충 위 코드들 따라 쳐봤는데 UnboundLocalError가 뜸
Traceback (most recent call last):
File "Desktop\Code\a.py", line 35, in <module>
enchant_i()
File "Desktop\Code\a.py", line 16, in enchant_i
if enchant_num < percent:
^^^^^^^
UnboundLocalError: cannot access local variable 'percent' where it is not associated with a value
아래 UnboundLocalError~ 부분 검색하면 이런 Stackoverflow 글 발견
https://stackoverflow.com/questions/74412503/cannot-access-local-variable-a-where-it-is-not-associated-with-a-value-but
위에서 추정한대로 스코프 문제로 없는 지역 변수를 찾을려고 해서 에러가 발생한듯. 위 글대로 함수 안에서 global percent 같이 전역 변수 사용한다고 명시하는 방법이 있을듯
Traceback (most recent call last):
File "/data/user/0/com.kvassyu.coding.py/files/default.py", line 35, in <module>
enchant_i()
File "/data/user/0/com.kvassyu.coding.py/files/default.py", line 20, in enchant_i
if enchant_num < percent:
UnboundLocalError: local variable 'percent' referenced before assignment
이렇게 나오네요 늦게 와서 죄송합니다ㅎㅎ
대충 위 코드들 따라 쳐봤는데 UnboundLocalError가 뜸 Traceback (most recent call last): File "Desktop\Code\a.py", line 35, in <module> enchant_i() File "Desktop\Code\a.py", line 16, in enchant_i if enchant_num < percent: ^^^^^^^ UnboundLocalError: cannot access local variable 'percent' where it is not associated with a value 아래 UnboundLocalError~ 부분 검색하면 이런 Stackoverflow 글 발견 https://stackoverflow.com/questions/74412503/cannot-access-local-variable-a-where-it-is-not-associated-with-a-value-but 위에서 추정한대로 스코프 문제로 없는 지역 변수를 찾을려고 해서 에러가 발생한듯. 위 글대로 함수 안에서 global percent 같이 전역 변수 사용한다고 명시하는 방법이 있을듯