Python Python Collections (2016, retired 2019) Dungeon Game Hit points

Joao Cid
Joao Cid
7,005 Points

What's wrong with the code? The examples tested work fine.

Hi... No sure what can be wrong with my code for this challenge... In fact, it works with the 3 examples presented above in the comments, as also with some others I tried on my own, but I am still getting the message "Bummer: Try again!". Thanks in advance for any hint or advice.

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
    dir_x, dir_y = direction
    new_x_try = x + dir_x
    new_y_try = y + dir_y
    if new_x_try < 0 or new_x_try > 9 or new_y_try < 0 or new_y_try > 9:
        hp -= 5
    else:
        x, y = new_x_try, new_y_try
    return x, y, hp

2 Answers

Joao Cid
Joao Cid
7,005 Points

Hi, Brendan... many thanks for your prompt reply... Something should be wrong, still... as I still can't finish it and move forward. I have tried to delete everything and re-paste it, but still no success... As said before, the code runs fine in the Workspaces and the tests I have tried run successfully, bu I would like to finish this cleanly. Again, many thanks for your time. P.S.: I even have tried to logout and lo in again... just i case, by the way... ;)

Chul Kim
Chul Kim
2,341 Points

sometimes it helps to re-type the solution instead of just pasting.

Joao Cid
Joao Cid
7,005 Points

Hi, Chul Kim, many thanks for your reply and suggestion... In fact, someone (and/or somehow) should have reset it in the meanwhile and after re-typing exactly the same, it finally worked... :) Again, many thanks.