Why does Python act as if my code isn't defined?

I’m trying to create a simple mario-inspired video game with Python and I keep on running into countless issues. Now, Replit is acting as if ‘game_state’ is not defined when it is. Why am I getting this error message if it’s defined?

The game_state variable is defined in the mario_game_level_1 function, so it’s defined only in that function. The while loop is in global code, so it can’t access variables in the function scope.