How to beat logical path

please help me beat logical path how to beat it? :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :sweat: :exploding_head: :exploding_head: :exploding_head:

Can you show us your code so we can help you?

Properly formatted, per this topic, please:
[Essentials] How To Post/Format Your Code Correctly

I don’t have one here is the code it gives you# 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)

If EITHER secretA or secretB is true, take the high path.

hero.moveXY(38, 24)

If secretB is NOT true, take the high path.

hero.moveXY(50, 24)

I will let @dedreous to help you because I have to go to bed. Bye!

Ok, please read the topic I just sent you. It will be crucial, if not required, should you need help in future levels.

Here is how your last post should look:


I don’t have one here is the code it gives you# Get two secret true/false values from the wizard.

# 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.

hero.moveXY(38, 24)
# If secretB is NOT true, take the high path.

hero.moveXY(50, 24)

oh ok thanks
:grinning: :grinning:

So, with that being said, the concept this lesson covers is the use of logical operators…and, or, not.

The idea is to use if statements to test if a certain condition is true and then move according the result of that test.

1 Like

ok can I have the soulotion

No, that is not what this forum is here for. We are here to help, guide and even further teach coding techniques. As per the Welcome topic at the top of the forum, posting solutions is not allowed:

  • You may not post solutions. It is strongly against the rule and might result in a mute or ban.
2 Likes

OK SORRY I think I got an answer

I only see… one if statement.

Of course, that is the β€˜Restart’ code…what you get when you first visit the level, or restart it.

I do NOT get any of this at all!!!

7:30-8:00 I will be here

Welcome to the forum @YoYo99 :partying_face: This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!

Please post your code so we can help you, an don’t forget to format it using this button:

All right I’m here now, sending my work…

1 Like
# 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.
if secretC:
    hero.moveXY(32, 33)
else:
    hero.moveXY(32, 15)
hero.moveXY(38, 24)
# If secretB is NOT true, take the high path.
if SecretC:
    hero.moveXY(44, 33)
else:
    hero.moveXY(44, 15)
hero.moveXY(50, 24)

Please Help me @Aya :pray:

so here, you cannot use secretC again because it is BOTH secretA and secretB
they are asking you for β€œor” so you can either make a new variable and assign it to secretA or secretB or you can just put it directly in the if-statement.

same goes for here, they are asking you if secretB is NOT TRUE or basically False. So again, instead of secretC, you can make a variable having the value of not secretB or directly putting it in the if-statement