Help me to fix this code plz

def game_code():
input(“Do you want to start on easy, medium, or hard---->”)
def easy_boss():
user_number = -1
secret_number = 5914
while user_number != secret_number:
penup()
goto(0,0)
pendown()
color(“white”)
seth(0)
user_number = int(input(“Guess a number 1-10000–>”))
clear()
if user_number == secret_number:
right(45)
pensize(7)
color(“green”)
backward(25)
forward(50)
left(105)
forward(100)
hideturtle()
penup()
goto(0,0)
clear()
write(“Leve”)
elif user_number > secret_number:
color(“red”)
pensize(7)
color(“red”)
right(90)
forward(100)
left(135)
forward(25)
backward(25)
left(90)
forward(25)
elif user_number < secret_number:
color(“red”)
pensize(7)
color(“red”)
left(90)
forward(100)
right(135)
forward(25)
backward(25)
right(90)
forward(25)
def medium_boss():
user_number = -1
secret_number = 11057
while user_number != secret_number:
penup()
goto(0,0)
pendown()
color(“white”)
seth(0)
user_number = int(input(“Guesse a number 1-100000–>”))
clear()
if user_number == secret_number:
right(45)
pensize(7)
color(“green”)
backward(25)
forward(50)
left(105)
forward(100)
hideturtle()
penup()
goto(0,0)
clear()
write(“Leve”)
elif user_number > secret_number:
color(“red”)
pensize(7)
color(“red”)
right(90)
forward(100)
left(135)
forward(25)
backward(25)
left(90)
forward(25)
elif user_number < secret_number:
color(“red”)
pensize(7)
color(“red”)
left(90)
forward(100)
right(135)
forward(25)
backward(25)
right(90)
forward(25)
def hard_boss():
user_number = -1
secret_number = 9169165
while user_number == secret_number:
penup()
goto(0,0)
pendown()
color(“white”)
seth(0)
user_number = int(input(“Guesse a number 1-10000000–>”))
clear()
if user_number == secret_number:
right(45)
pensize(7)
color(“green”)
backward(25)
forward(50)
left(105)
forward(100)
hideturtle()
penup()
goto(0,0)
clear()
write(“Leve”)
elif user_number > secret_number:
color(“red”)
pensize(7)
color(“red”)
right(90)
forward(100)
left(135)
forward(25)
backward(25)
left(90)
forward(25)
elif user_number < secret_number:
color(“red”)
pensize(7)
color(“red”)
left(90)
forward(100)
right(135)
forward(25)
backward(25)
right(90)
forward(25)
game_code()
if game_code() == easy:
easy_boss()
if game_code() == medium:
medium_boss()
if game_code() == hard:
hard_boss()
penup()
goto(0,0)
pendown()
write(“You win”, font=(“Times New Roman”, 20), align=“center”)

When i run this code and write easy medium or hard it says that easy is not defined on line 142 but i use an if satement that says if game_code is equal to easy then go to easy boss. game code is the user input. You will have to paste this into a code to understand

In order to preserve formatting, please select any code or traceback that you post and then click the </> button.

Look at this part:

game_code()
if game_code() == easy:
    easy_boss()
if game_code() == medium:
    medium_boss()
if game_code() == hard:
    hard_boss()

First it calls game_code, which asks the player and discards the answer. The function doesn’t explicitly return anything, so it defaults to returning None.

Then it calls game_code again, and function returns None.

Then it checks whether the result returned by game_code, which is None, remember, is equal to the value of easy.

But what is the value of easy?

You haven’t told it.

What you should’ve written was a string literal "easy".

Similarly for medium and hard.

In fact, even when those problems are fixed, it’ll ask the player each time game_code is called, and that part of the code calls it 4 times (once initially plus once in each if statement).

Some other points: in easy_boss and medium_boss, the while loops will terminate when user_number == secret_number, so the following if condition will always be true and the elif conditions will always be false. In hard_boss the condition of the while loop is the opposite of those in the other functions; is that intentional?

This function game_code calls input() and discards its result. It
looks like you want to receive the result. So:

 def game_code():
     return input("Do you want to start on easy, medium, or hard---->")

so that the function returns the value returned by input().

Then this code:

 game_code()
 if game_code() == easy:
     easy_boss()
 if game_code() == medium:
     medium_boss()
 if game_code() == hard:
     hard_boss()

First: writing easy cause Python to try to use a variable called
easy. You don’t have one. You want to compare to a string value i.e.
"easy".

Also, game_code() runs (and, as written, discards) the game_code
function. So you run it several times in the above code. What you
actually want is to run it once and then compare the value it returns:

 mode = game_mode()
 if mode == "easy":
     ... etc ...

Reference: