I need some help with “logical path”
here is a picture of the error:
rewrite true and false to
if secretA or secretB == True:
if secretB == False:
Would you use the </> sign to put your code?
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.
:(:( 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?
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 EITHER secretA or secretB is true, take the high path.
if secretA and secretB == True:
If secretB is NOT true, take the high path.
if secretB == False:
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. hero.pickUpFlag(flag) elif enemyDistance < 10: # Only attack if the enemy distance is < 10 meters hero.attack(enemy) hero.attack(enemy)
Wait solved it:sweat_smile:
yay that comment is much shorter now
can any body help me with my code it keeps killing me
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.