-2

I'v set player to "x", and defined a function than reverses the player (you will see it in the code). Can someone please help me?

player = "x"

def update_player(player):
    if player == "x":
        player = "y"
    else:
        player = "x"
    return player

update_player(player) #called the function with argument player
print(player)

  • 4
    You need to assign the return - `player = update_player(player)`. Or you could use player as a global variable instead of a parameter. – jonrsharpe Sep 10 '20 at 07:06
  • thanks, it helped me. If you will write it as an answer, i will mark it with the green "v". Thank you so much! – Mattan Elkaim Sep 10 '20 at 07:09

1 Answers1

0

You are printing the same variable instead of printing the function.Edit your code like this.

player = "x"
def update_player(player):
    if player == "x":
        player = "y"
    else:
        player = "x"
    return player
k=update_player(player)
print(k)