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 ▸

h


Print "Hello World!" ten times without typing (or pasting) the print function more than once


Given a list of N numbers, use a single list comprehension to produce a new list that only contains those values that are: (a) even numbers, and (b) from elements in the original list that had even indices .


Define a function that takes in the age of the user and adds it to an output sentence such as "You are ..... old".