What's the difference between a local and a global variable?

A global variable can be accessed from anywhere within the program whereas a local one can only be accessed from within the method it's declared in.

JH

Related Python Mentoring answers

All answers ▸

Explain how python programs are structured and give an example of how methods are initiated


Demonstrate a recursive solution to calculate the factorial of a number


What built-in types does python provide?


What does __init__ mean?