Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Logical Path - not working unless I submit it

My code works when I submit it, but doesn’t work when running it. See code below, that works.
(I hope this is the right way to submit)

if secretA or secretB == "true":
    hero.moveXY(32, 33)
    hero.moveXY(38, 24)
else:
    hero.moveXY(32, 15)
# If secretB is NOT true, take the high path.
if secretB != "true":
    hero.moveXY(44, 34)
    hero.moveXY(50, 24)
else:
    hero.moveXY(44, 15)

1 Like

Try to put those two after the if statements.

Andrei

1 Like

Try something like this:

if promiseX or promiseY is True:
1 Like

Yes, this is a good submittal. :slight_smile:

To expand on what Andrei was saying:

The second move statement will only be executed if the ‘if’ statement is true. Instead, no matter which path is selected, you always want the hero to move back to the middle…to do this, the second move statement needs to be outside of the ‘if’ block; ideally, after the ‘else’ statement.

2 Likes

Well done and that is a very good point @dedreous. :+1:

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.