I entered a variable in python, but it will not be accepted. I'm not sure why this is happening. I have tried to change the name of the variable, changing capitalization in the name of it, and changing the input key for the function. My code is:
import turtle
startup = 1
screen = turtle.Screen()
screen.bgcolor("black")
screen.bgpic("Assets/Title.png")
screen.title("Game")
def startgame():
if startup == 1:
screen.bgpic("Assets/Title_Two.png")
startup = 2
turtle.listen()
turtle.onkey(startgame, "Left")
The only error message I've gotten is:
>>> Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files (x86)\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\Program Files (x86)\Python37-32\lib\turtle.py", line 686, in eventfun
fun()
File "C:\Users\Adam\OneDrive\Programming Stuff\Game\Game.py", line 9, in startgame
if startup == 1:
UnboundLocalError: local variable 'startup' referenced before assignment