[SOLVED] Difficulty with Either/Or statements in level Logical Path

Could you post your newest code formatted correctly?
Lydia

# Get two secret true/false values from the wizard.
# Check the guide for notes on how to write logical expressions.
hero.moveXY(14, 24)
secretA = hero.findNearestFriend().getSecretA()
secretB = hero.findNearestFriend().getSecretB()

# If BOTH secretA and secretB are true, take the high path; otherwise, take the low path.
secretC = secretA and secretB
if secretC:
    hero.moveXY(20, 33)
else: 
    hero.moveXY(20, 15)
hero.moveXY(26, 24)
# If EITHER secretA or secretB is true, take the high path.

    

It’s difficult for me to understand.

In this one, notice the or.
So what would you do?
Lydia

That is still something too difficult for me to understand. I don’t know how to type that down without an error warning popping up.

So this is good,
Basically you are doing almost exact same except changing the and to or.
Lydia

I tried doing that, but when I repeat that, I get killed. What do I do?

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

So first you need to put

hero.moveXY(14, 24)
secretA = hero.findNearestFriend().getSecretA()
secretB = hero.findNearestFriend().getSecretB()

at the top of your code, it seems like you’ve deleted this part.

Second,
You need to add

secretC = secretA and secretB
if secretC:
    hero.moveXY(20, 33)
else:
    hero.moveXY(20, 15)
hero.moveXY(26, 24)

before

Third,
Before

You need to add
secretB = not secretA

And you should be good!
Lydia

I did that, but I got killed again.

# Get two secret true/false values from the wizard.
# Check the guide for notes on how to write logical expressions.
hero.moveXY(14, 24)
secretA = hero.findNearestFriend().getSecretA()
secretB = hero.findNearestFriend().getSecretB()

# If BOTH secretA and secretB are true, take the high path; otherwise, take the low path.
secretC = secretA and secretB
if secretC:
    hero.moveXY(20, 33)
else: 
    hero.moveXY(20, 15)
hero.moveXY(26, 24)
# If EITHER secretA or secretB is true, take the high path.
secretC = secretA or secretB
if secretC: 
    hero.moveXY(32, 33)
else:
    hero.moveXY(32, 15)
hero.moveXY(38, 24)
secretB = not secretA
if secretC:
    hero.moveXY(44, 33)
else:
    hero.moveXY(44, 15)
hero.moveXY(50, 24)

Your code looks fine! Just submit!
Lydia

I did, but it still isn’t working for some reason. Every time I try to play it, I get killed.

You seem to have deleted the instruction for the third step. It’s

# If secretB is NOT true, take the high path.

That isn’t what you’ve put.

Jenny

Jenny, for my code, I put secretB = not secretA It worked for me.
Lydia

It worked!! After so many days, it finally works!!!

Congrats on passing the level! Make sure to check the tick mark next to the comment that helped you the most!
Lydia