Question
Python basics
- I cannot use my variable inside my function/my variable inside the function is “None” “NoneType”/how can I have save previous values between function calls
In python, when creating variables, global ones are available anywhere in the script, and local ones only inside the scope (for example function) . where they were created. the global keyword on line 32 is not creating the variable, just telling python that this name represents a global variable created somewhere else. you need this in case you want to change a global variable inside a function. You must create this variable somewhere else! refer to this thread showing an example
The European Commission's support for the production of this publication does not constitute an endorsement of the contents, which reflect the views only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.