Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Afrid Mondal
9,509 PointsFunction is not working properly
Dear All, This function should return updated value based on the input I am giving. But its returning the output without modifying anything. Please help.
def move_player(player, move):
x, y = player
if x == "LEFT":
x -= 1
if x == "RIGHT":
x += 1
if y == "UP":
y -= 1
if y == "DOWN":
y += 1
player = x, y
return player
print(move_player((5, 6), input("> ").upper()))
1 Answer

Oskar Lundberg
9,534 Pointsdef move_player(player, move):
x, y = player
if move.upper() == "LEFT":
x -= 1
if move.upper() == "RIGHT":
x += 1
if move.upper() == "UP":
y -= 1
if move.upper() == "DOWN":
y += 1
player = x, y
return player
I don't know how the rest of your code looks, but try this^. It is probably your move input that will be one of the following: LEFT", "RIGHT", "UP" or "DOWN". So you will probably want to check move and then change the coordinates of the player (x, y), depending on the Move direction. Feel free to respond back if this didn't help you, then I can share my full code for this scipt
Afrid Mondal
9,509 PointsAfrid Mondal
9,509 PointsReally Oskar, I did silly mistake. Thanks for your help. Got it. :)