Variables created inside a function are local. They exist only inside that function:
def my_func():
x = 10 # Local variable
print(x)
my_func() # Prints 10
print(x) # Error! x doesn't exist here
Variables created outside functions are global. They're visible everywhere, including inside functions.
This separation prevents functions from accidentally overwriting each other's variables.