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

Thomas Trabue
Thomas Trabue
11,775 Points

I can't see what I did wrong on the HP problem...

Hey all,

I am having the darnedest time trying to figure out what's wrong with my code! I tested it on my local Linux development setup, and it's worked on all of the test cases I have given it. Do you see any problems here? I'm not getting any useful output from the Treehouse code checker, either. I really do wish that they would program that code checker to provide more useful feedback than "Try again!". Doesn't really help me see what the problem is.

Thank you all in advance!

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
    x_to_move, y_to_move = direction
    if x == 0 and x_to_move == -1:
        hp -= 5
    elif x == 9 and x_to_move == 1:
        hp -=5
    elif y == 0 and y_to_move == -1:
        hp -= 5
    elif y == 9 and y_to_move == 1:
        hp -=5
    else:
        x += x_to_move
        y += y_to_move
    return x, y, hp

1 Answer

Eric McKibbin
MOD
Eric McKibbin
Treehouse Moderator 11,441 Points

Hi Thomas,

Your code here is good. It passes the challenge for me on a copy and paste. Good work!

Unfortuantely it seems like you've run into an issue with the Workspaces. This can happen sometimes and some of the Python challenges seem sensitive to it. Try logging out of Treehouse, clearing your browser cache, then closing your browser. It should then work fine.

Sorry, it can be frustrating! I realise that you've run into this at least twice now. I think it happened 3 or 4 times to me going through Python Basics and Intermediate Python.

The Treehouse team are aware that this is an occasional issue, I've been told there is some discussion of redoing the Python challenges, but I don't have any insight as to timeline or roadmap beyond that.

The good news is that your code works :)

Cheers,

Eric