# \[SOLVED\] Help with "logical path"

**URL:** https://discourse.codecombat.com/t/solved-help-with-logical-path/14098
**Category:** Solved
**Created:** [March 6, 2018, 12:25am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098 "2018-03-06T00:25:52Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ZackAttack04](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zackattack04/32/6659_2.png) [@ZackAttack04](https://discourse.codecombat.com/u/ZackAttack04)
#### Post date: [March 6, 2018, 12:25am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/1 "2018-03-06T00:25:53Z")

</div>

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

 ![19%20PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a2bf2abf0e5c18d27704f5cf67e4e8d4406dc31f.png)

---

<div class="post-metadata">

### Author: ![Seojin\_Roy\_Lee](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/seojin_roy_lee/32/23539_2.png) [@Seojin\_Roy\_Lee](https://discourse.codecombat.com/u/Seojin_Roy_Lee)
#### Post date: [March 6, 2018, 12:30am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/2 "2018-03-06T00:30:58Z")

</div>

rewrite true and false to `True` and `False`.

edit:  
type  
`if secretA or secretB == True:`  
and  
`if secretB == False:`

---

<div class="post-metadata">

### Author: ![Gamestack](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@Gamestack](https://discourse.codecombat.com/u/Gamestack)
#### Post date: [March 6, 2018, 1:49am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/3 "2018-03-06T01:49:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ZackAttack04](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zackattack04/32/6659_2.png) [@ZackAttack04](https://discourse.codecombat.com/u/ZackAttack04)
#### Post date: [March 6, 2018, 5:17pm UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/4 "2018-03-06T17:17:40Z")

</div>

thanks @Seojin_Roy_Lee it worked after i did that

---

<div class="post-metadata">

### Author: ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)
#### Post date: [March 6, 2018, 5:21pm UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/6 "2018-03-06T17:21:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Gamestack](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@Gamestack](https://discourse.codecombat.com/u/Gamestack)
#### Post date: [March 7, 2018, 12:03am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/7 "2018-03-07T00:03:57Z")

</div>

Put [SOLVED].  
(20 chars)

---

<div class="post-metadata">

### Author: ![Tin\_Lap\_CHU\_066.3](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tin_lap_chu_066.3/32/10337_2.png) [@Tin\_Lap\_CHU\_066.3](https://discourse.codecombat.com/u/Tin_Lap_CHU_066.3)
#### Post date: [December 21, 2018, 10:23am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/8 "2018-12-21T10:23:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)
#### Post date: [December 21, 2018, 10:25am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/9 "2018-12-21T10:25:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Tin\_Lap\_CHU\_066.3](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tin_lap_chu_066.3/32/10337_2.png) [@Tin\_Lap\_CHU\_066.3](https://discourse.codecombat.com/u/Tin_Lap_CHU_066.3)
#### Post date: [December 21, 2018, 10:30am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/10 "2018-12-21T10:30:49Z")

</div>

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)  
else:  
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)  
else:  
hero.moveXY(32, 15)

# If secretB is NOT true, take the high path.

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

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

---

<div class="post-metadata">

### Author: ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)
#### Post date: [December 21, 2018, 11:40am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/11 "2018-12-21T11:40:51Z")

</div>

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.

> [@\[Essentials\] How To Post/Format Your Code Correctly](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521):
>
> Formatting your code before posting code is essential to our community, and if you don’t we might not be able to help frowning Everyone must know how to format ALL of your code properly. It’s really easy and only requires a very small amount of effort. To post your code from the game , use the \</\> button or it won’t format properly. When you click the \</\> button, the following will appear: Please paste ALL …

---

<div class="post-metadata">

### Author: ![Tin\_Lap\_CHU\_066.3](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tin_lap_chu_066.3/32/10337_2.png) [@Tin\_Lap\_CHU\_066.3](https://discourse.codecombat.com/u/Tin_Lap_CHU_066.3)
#### Post date: [December 26, 2018, 9:56am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/12 "2018-12-26T09:56:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)
#### Post date: [December 26, 2018, 11:04am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/13 "2018-12-26T11:04:29Z")

</div>

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.

> [@Tin\_Lap\_CHU\_066.3](#):
>
> and i did exactly what the video did

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

---

<div class="post-metadata">

### Author: ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)
#### Post date: [December 27, 2018, 12:06am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/14 "2018-12-27T00:06:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Tin\_Lap\_CHU\_066.3](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tin_lap_chu_066.3/32/10337_2.png) [@Tin\_Lap\_CHU\_066.3](https://discourse.codecombat.com/u/Tin_Lap_CHU_066.3)
#### Post date: [December 27, 2018, 3:57am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/15 "2018-12-27T03:57:39Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![Tin\_Lap\_CHU\_066.3](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tin_lap_chu_066.3/32/10337_2.png) [@Tin\_Lap\_CHU\_066.3](https://discourse.codecombat.com/u/Tin_Lap_CHU_066.3)
#### Post date: [December 27, 2018, 4:08am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/16 "2018-12-27T04:08:52Z")

</div>

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

```python
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)

```

Help plz

---

<div class="post-metadata">

### Author: ![Tin\_Lap\_CHU\_066.3](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tin_lap_chu_066.3/32/10337_2.png) [@Tin\_Lap\_CHU\_066.3](https://discourse.codecombat.com/u/Tin_Lap_CHU_066.3)
#### Post date: [December 27, 2018, 4:13am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/17 "2018-12-27T04:13:17Z")

</div>

Wait solved it:sweat\_smile:

---

<div class="post-metadata">

### Author: ![Seojin\_Roy\_Lee](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/seojin_roy_lee/32/23539_2.png) [@Seojin\_Roy\_Lee](https://discourse.codecombat.com/u/Seojin_Roy_Lee)
#### Post date: [February 13, 2019, 3:39am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/18 "2019-02-13T03:39:26Z")

</div>

yay that comment is much shorter now

---

<div class="post-metadata">

### Author: ![hi1234578](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@hi1234578](https://discourse.codecombat.com/u/hi1234578)
#### Post date: [March 18, 2021, 9:17pm UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/19 "2021-03-18T21:17:39Z")

</div>

can any body help me with my code it keeps killing me  
 ![Screenshot 2021-03-18 at 2.17.08 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/7/0/700b463e446331774960324c4eb08243d5d03dae.png)

---

<div class="post-metadata">

### Author: ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)
#### Post date: [March 18, 2021, 9:47pm UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/20 "2021-03-18T21:47:44Z")

</div>

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](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601), which shows all essentials of this board! Thanks!

---

<div class="post-metadata">

### Author: ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)
#### Post date: [March 19, 2021, 11:09am UTC](https://discourse.codecombat.com/t/solved-help-with-logical-path/14098/21 "2021-03-19T11:09:19Z")

</div>

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