## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today. PLUS

# Movement.py

Hi, there.

Could anybody clarify why my code doesn't work but it works in shell.

Thank you

movement.py
```# EXAMPLES:
# move((1, 1, 10), (-1, 0)) => (0, 1, 10)
# move((0, 1, 10), (-1, 0)) => (0, 1, 5)
# move((0, 9, 5), (0, 1)) => (0, 9, 0)

def move(player, direction):
x, y, hp = player

if x == 0:
hp -= 5
if x == -1:
hp -= 10
if y == 0:
hp -= 5
if y == -1:
hp == 10

return x, y, hp
``` STAFF

You're not accounting for the direction the player is trying to travel. Just because the player is at `x=0` doesn't mean they lose 5 HP. They'd only lose that if they were trying to travel to `x=-1`. Same for other cases where they're trying to leave the map. Hi there,

This is my solution that worked:

```def move(player, direction):
x, y, hp = player
xd, yd = direction
if x+xd < 0 or x+xd > 9:
hp -= 5
pass
else:
x += xd
if y+yd < 0 or y+yd > 9:
hp -= 5
pass
else:
y += yd
return x, y, hp
```

I know it's been a long time since your post. Can you explain why are you using "pass" in your conditions?