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 ▸

When to use a dectionary or a list


Using the shared code editor, write a recursive function for calculating a factorial of an input parameter.


How would you loop over every key and value in a python dictionary?


Write a function that takes a list of numbers as input, and outputs the average of the numbers. The function should catch any errors.