Daniel Escobar2,580 Points
I need help with this Challenge Task
I am not sure what am I doing wrong. I tried so many ways. Can someone help me please.
def move(player, direction): x, y, hp = player x1, y1 = direction if x + x1 <= 0: x += 1 hp=- 5 elif x + x1 >= 9: x -=1 hp=- 5 elif y + y1 <= 0: y += 1 hp=- 5 elif y + y1 >= 9: y -= 1 hp=- 5 else: x = x + x1 y = y + y1 return x, y, hp
Steven Parker168,137 Points
You've got the right idea, but there are a few implementation issues. Here are a few hints:
- 0 and 9 are part of the grid, so the tests should allow them (just not anything beyond)
- when a wall would be hit, the x or y should not be changed
- when reducing
hp, the subtracting assignment operator is "
-=" (not "