Skip to content

Instantly share code, notes, and snippets.

@y56
Last active January 2, 2020 02:52
Show Gist options
  • Save y56/f5a6a689e3993643ee8389124e866dee to your computer and use it in GitHub Desktop.
Save y56/f5a6a689e3993643ee8389124e866dee to your computer and use it in GitHub Desktop.
global-keyword-in-python
https://www.geeksforgeeks.org/global-keyword-in-python/
To access a global variable inside a function there is no need to use global keyword.
If we need to assign a new value to a global variable then we can do that by declaring the variable as global.
This output is an error because we are trying to assign a value to a variable in an outer scope. This can be done with the use of global variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment