[SOLVED] Help with "logical path"

I need some help with “logical path”
here is a picture of the error:

rewrite true and false to True and False.

if secretA or secretB == True:
if secretB == False:

1 Like

Would you use the </> sign to put your code?

1 Like

thanks @Seojin_Roy_Lee it worked after i did that

It’s great that you were able to complete this level but please do not post finished code or solutions here. The purpose of this board is to help people learn and simply providing solutions is counterproductive toward that goal. Thanks.

(20 chars)

:(:(:frowning: this lev… i have 0 idea.

Please post your code. We can’t help unless you post what you’ve done so far.

can you help me with this level? i am stuck on it… i copied your code, maybe bug or error?
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)
hero.moveXY(20, 15)
hero.moveXY(26, 24)

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

if secretA and secretB == True:
hero.moveXY(32, 33)
hero.moveXY(32, 15)

If secretB is NOT true, take the high path.

if secretB == False:
hero.moveXY(44, 32)
hero.moveXY(44, 15)

hero.moveXY(50, 24)https://codecombat.com/play/level/logical-path?

Copied code from where? If you copied it from here in Discourse then it won’t work. We don’t allow anyone to post working code. We only allow code that isn’t working so we can help you fix it.

Please learn to post your code properly with formatting. Directions are here.

but i copied it from my codecombat account…
not from the discourse!
and i did exactly what the video did… would you help please?

Your computer doesn’t work any different than anyone else’s. If you had followed instructions then the code would display with the proper formatting.

What video? Please provide a link to this video because I don’t know what you mean.

There’s a video guide attached to the level if you’re a subscriber.

Hmmm finished the level!
Just found out you needed to PLACE the flag for it to work!
Also found out that the hero will auto set routes if the flag is around a corner… still works! And it’s faster!
No more slow hero!

I need help with Mind the trap! What is wrong with my code?!

while True:
    flag = hero.findFlag()
    enemy = hero.findNearestEnemy()
    Distance = hero.distanceTo(enemy)
    if flag:
        # Pick up the flag.
    elif enemyDistance < 10:
        # Only attack if the enemy distance is < 10 meters

Help plz

Wait solved it:sweat_smile:

yay that comment is much shorter now

can any body help me with my code it keeps killing me
Screenshot 2021-03-18 at 2.17.08 PM

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

I’m afraid logic in python doesn’t quite work how it does in English. The first one is ok, and so is the second, although I’m not sure it works exactly how you think it does.
if you say: if secretA or secretB == True, python is not checking if secretA and secretB == True. It’s checking if secretB == True, and if secretA exists, which in this case is the same as it being true, so the code will work, but bear in mind that if you do something like:
if enemy1.type or enemy2.type == “ogre”
It will only check if enemy2.type == “ogre”, and it will check if enemy1 has a type property, which isn’t the same thing.
For Number 3:
They’ve asked you to check if secretB is not True. Why have you used secretA as well? Just use secretB and it will work.