tickets_remaining is a global variable and in Python, there is no problem in using it inside a function. However, you're not just using it, you're updating it from inside the function. To change the value of a global variable from inside a function in Python, according to the w3school...
ExampleGet your own Python Server Make a function inside a function, which uses the variable x as a non local variable: defmyfunc1(): x ="John" defmyfunc2(): nonlocal x x ="hello" myfunc2() returnx print(myfunc1()) Try it Yourself » ...