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
Answered by James H. Python tutor

1677 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Sort a given input of lowercase letters alphabetically


Whats is the difference between a function and a procedure?


[Exam style] Python is an interpreted language. Explain what this means and how interpreted languages differ from compiled languages.


Which four data types are used in Python? Can you give an example of each?


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences