in Python by
Q:
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.

Click here to read more about Python
Click here to read more about Insurance

Related questions

0 votes
asked Mar 10, 2020 in C Plus Plus by rahuljain1
0 votes
asked Jul 2, 2020 in Python by GeorgeBell
0 votes
asked May 17, 2020 in Python by SakshiSharma
0 votes
0 votes
asked Jun 30, 2020 in Python by GeorgeBell
0 votes
asked May 17, 2019 in Python by Derya
...