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! While you're at it, check out some resources Treehouse students have shared here.

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

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

Thomas Trabue
Thomas Trabue
11,819 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 M
Eric M
11,545 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