
Predict
Inside and Outside
Variables created inside a function are local. They live only while the function runs. They're separate from variables outside, even ones with the same name. Variables made at the top level of your program are global.
Pip tip: There is a
globalkeyword that lets a function change a global variable, but it makes code hard to follow. Returning a value is almost always better.
fuel = 10
def refill():
fuel = 99
print("inside:", fuel)
refill()
print("outside:", fuel)