Logical Path: Help me!


#1
# 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?


#2

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


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

should be

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

only one equal sign is needed


#4

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


#5

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


#6

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)

#7

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.


#8

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)


#9

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


#10

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


#11

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


#12

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):


#13

use this code

(Solution removed)


#14

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.