I am trying to use a global variable inside a function, and despite declaring the variable globally, and initializing its value, I get the following error:
Traceback (most recent call last):
File "test.py", line 11, in <module>
main()
File "test.py", line 8, in main
func_check()
File "test.py", line 5, in func_check
value += 45
UnboundLocalError: local variable 'value' referenced before assignment
Following is the code snippet:
value = 0
def func_check():
value += 45
def main():
func_check()
if __name__ == "__main__":
main()