0 votes
in Python by
What are the rules for local and global variables in Python?

1 Answer

0 votes
by

In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a value anywhere within the function’s body, it’s assumed to be a local unless explicitly declared as global.

Requiring global for assigned variables provides a bar against unintended side-effects.

Related questions

0 votes
asked Jun 30, 2020 in Python by GeorgeBell
0 votes
asked Jun 28, 2020 in Python by Robindeniel
...