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.

Answered by James H. Python tutor

1461 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Create an algorithm that can be used as a guessing game. Make sure to import random at the start.


How would you get a piece of code to print the numbers 1 to 10


What is the difference between & and && operators?


Write a short program to print all the even numbers 1 to 100


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences