UnboundLocalError: cannot access local variable 'x' where it is not associated with a value

Опубликовано: 12 Октябрь 2024
на канале: Python for Everyone
4,983
71

If you are watching this video, you probably just got this Unbound Local error message in Python. But why does it happen and how can you fix it? In this video you learn two solutions to the problem.

C H A P T E R S
0:10 Python can access variables outside of the function
0:45 Scoping rules
1:30 The cause of an UnboundLocalError
2:40 Quick fix with the global keyword
3:25 Decouple the function to solve the problem

M Y O N L I N E T R A I N I N G
🎓Like my style of teaching? Try free chapters of online courses: https://pythonforeveryone.com

L I N K S I N T H E V I D E O
https://docs.python.org/3/faq/program...

#unbound #local #error