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

1570 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Explain the difference between local and global variables


What can I do with Python?


What is the difference between a for loop and a while loop?


Create an rock, paper, scissors game. The user should input one option, and the computer should play randomly.


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences