Logical Path: Help me!

# Get two secret true/false values from the wizard.
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.
# Check the guide for notes on how to write logical expressions.
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 (secretA == "true" or secretB == "true"):
    hero.moveXY(32, 33)
        

# If secretB is NOT true, take the high path.
if (secretB !== "true"):
    hero.moveXY(44,33)

It says: Fix your code: Parentheseas must match. What parantheseas aren’t matching?

I don’t think you are using python but maybe your third if is meant to look like this

if (secretA == "true") or (secretB == "true"):
    hero.moveXY(32, 33)
        

and what language are you using?

p.s. if it’s python the parentheses are not needed

if (secretB !== "true"):
    hero.moveXY(44,33)

should be

if (secretB != "true"):
    hero.moveXY(44,33)

only one equal sign is needed

I am using Python thank you for helping me I will try it again right now:slight_smile:

Oh, I wasn’t sure, thanks a lot!

Here’s my code now and my pet cougar and I just stop when I’m in front of the first bunch of tress in the middle

# Get two secret true/false values from the wizard.
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.
# Check the guide for notes on how to write logical expressions.
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 (secretA == "true") or (secretB == "true"):
    hero.moveXY(32, 33)
    # If secretB is NOT true, take the high path.
    if (secretB != "true"):
        hero.moveXY(44, 33)

Okay so I look back at my code and your hero doesn’t get stuck but rather they stop because you need to write more code so your sA or sB needs tp changer to this.

if (secretA == "true") or (secretB == "true"):
    hero.moveXY(32, 33)
else:
       blah blah 
hero.moveXY(blah, blah)

I won’t tell you the code
and the sB !=

  if (secretB != "true"):
        hero.moveXY(44, 33)
  else:
    blah blah
hero.moveXY(blah, blah)

needs to do the same thing. After you do that you will have enough code.
and also don’t write

if secretA == "true" or secretB == "true":

you can get rid of the parentheses and == 'true" and change to

if secretA or secretB:

and for the not true you should write them as

if secretA == True:

the True should be light blue I am not sure if your method works or not but this one is faster.

I need help. The coding says I made a mistake but their is nothing wrong with it.

hero.moveXY(14, 24)
secretA = hero.findNearestFriend().getSecretA()
secretB = hero.findNearestFriend().getSecretB()
secretC = secretA and secretB
if secretC:
hero.moveXY(20, 33)
else:
hero.moveXY(20, 15)
hero.moveXY(26, 24)
secretD = secretA or secretB
if secretD:
hero.moveXY(32, 33)
else:
hero.moveXY(32, 16)
hero.moveXY(38, 24)
Secret = secretA not secretB
if secret:
hero.moveXY(44, 33)
else:
hero.moveXY(44, 15)
hero.moveXY(50, 24)

How do I do the last part where B is false in Lua.

you probally already beat it but i wanted to say thanks because your code helped me beat this stupid level been stuck for a whole day… under hero moveXY(38,24) should be this secretD = not secretB
than under than the last if secret should be if secretD: and remeber to format everything correctly, which i know you probally already have, thanks again

This is my code:

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

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

bla bla bla

if (secretA == True) or (secretB == True):
hero.moveXY(32, 33)
else:
hero.moveXY(32, 15)
hero.moveXY(38, 24)

bla bla bla

if secretB != True:
hero.moveXY(44, 33)
else:
hero.moveXY(44, 15)
hero.moveXY(50, 24)

I hope i help you

We can’t see the structure since you didn’t post your code correctly. From now on please paste the code from the game using the </> button so it is formatted properly. Help us help you.

That being said, why are you using parenthesis in this line?

if (secretA == True) or (secretB == True):

use this code

(Solution removed)

It’s great that you solved this level but please don’t post finished, working code or final solutions. The purpose of this board is to help people learn and simply providing solutions is counterproductive toward that goal. Thanks.

Please help me, I can’t see where I made mistakes

Hi welcome to the forum, sorry for the delay.
My advice would be to check secretA and secretB like they do here:

var secretC = secretA && secret B;

for all the secret checking, rather than doing this:

if (secretA == "true" or secretB = "true"):

mainly because the code above (the code you wrote) doesn’t work. Are you used to doing Python? Because you’ve used a : at the end of the if statement and an or in the middle. If not my advice would be to read the hints carefully as they tell you what you need to know.
So you could start line 16 like this:

var secretD = secretA || secretB // this is how you do or in javascript

and then move on from there.
You’re also missing the section where you go back down from the cross you go to.
E.g. the else part in the example code.
I hope this helps.
P.S. in future can you put your code actually onto the forum rather than in a screenshot: instructions here: How to Post Your Code With Radiant, Harmonious Formatting.

hey uh please format code use ‘’’ before and after putting code in

Anyways, uh my character always gets stuck on the last or middle tree or i fail and the wizard zaps me. my code:
‘’’# 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 secretA or secretB == “true”:
hero.moveXY(32, 33)
else:
hero.moveXY(32, 15)
hero.moveXY(38, 24)

If secretB is NOT true, take the high path.

if secretB == “false”:
hero.moveXY(44, 33)
if secretB == “true”:
hero.moveXY(44, 15)
hero.moveXY(50, 24)’’’

Sorry, didnt format correctly

# 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 secretA or secretB == "true":
    hero.moveXY(32, 33)
else:
    hero.moveXY(32, 15)
hero.moveXY(38, 24)
# If secretB is NOT true, take the high path.
if secretB == "false":
    hero.moveXY(44, 33)
if secretB == "true":
    hero.moveXY(44, 15)
hero.moveXY(50, 24)

There is something wrong with this line:

if secretA or secretB == "true":

Hint: The code you should replace that line with is very similar to your line for secretC:

if secretC: