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

1627 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

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 .


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


How can you take a list of numbers and add 3 to every number in the list using only one line of code?


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


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