# How to beat logical path

**URL:** <https://discourse.codecombat.com/t/how-to-beat-logical-path/22349>\
**Category:** Level Help\
**Created:** [June 18, 2020, 7:41pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349 "2020-06-18T19:41:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chihya\_957](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chihya_957/32/12811_2.png) [@Chihya\_957](https://discourse.codecombat.com/u/Chihya_957)\
**Post date:** [June 18, 2020, 7:41pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/1 "2020-06-18T19:41:33Z")

</div>

please help me beat logical path how to beat it? 😓 😓 😓 😓 😓 😓 😓 😓 😓 😓 😓 😓 😓 😓 😓 😓 😓 🤯 🤯 🤯

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 18, 2020, 7:42pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/2 "2020-06-18T19:42:27Z")

</div>

Can you show us your code so we can help you?

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 18, 2020, 7:43pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/3 "2020-06-18T19:43:09Z")

</div>

Properly formatted, per this topic, please:  
[[Essentials] How To Post/Format Your Code Correctly](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521)

---

<div class="post-metadata">

**Author:** ![Chihya\_957](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chihya_957/32/12811_2.png) [@Chihya\_957](https://discourse.codecombat.com/u/Chihya_957)\
**Post date:** [June 18, 2020, 7:44pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/4 "2020-06-18T19:44:21Z")

</div>

I don’t have one here is the code it gives you# 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)

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

hero.moveXY(38, 24)

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

hero.moveXY(50, 24)

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 18, 2020, 7:47pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/5 "2020-06-18T19:47:15Z")

</div>

I will let @dedreous to help you because I have to go to bed. Bye!

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 18, 2020, 7:47pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/6 "2020-06-18T19:47:30Z")

</div>

Ok, please read the topic I just sent you. It will be crucial, if not required, should you need help in future levels.

Here is how your last post should look:

* * *

I don’t have one here is the code it gives you# Get two secret true/false values from the wizard.

```python
# 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.

hero.moveXY(38, 24)
# If secretB is NOT true, take the high path.

hero.moveXY(50, 24)

```

---

<div class="post-metadata">

**Author:** ![Chihya\_957](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chihya_957/32/12811_2.png) [@Chihya\_957](https://discourse.codecombat.com/u/Chihya_957)\
**Post date:** [June 18, 2020, 7:48pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/7 "2020-06-18T19:48:38Z")

</div>

oh ok thanks  
😀 😀

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 18, 2020, 7:50pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/8 "2020-06-18T19:50:38Z")

</div>

So, with that being said, the concept this lesson covers is the use of logical operators…and, or, not.

The idea is to use if statements to test if a certain condition is true and then move according the result of that test.

---

<div class="post-metadata">

**Author:** ![Chihya\_957](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chihya_957/32/12811_2.png) [@Chihya\_957](https://discourse.codecombat.com/u/Chihya_957)\
**Post date:** [June 18, 2020, 7:51pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/9 "2020-06-18T19:51:36Z")

</div>

ok can I have the soulotion

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 18, 2020, 7:54pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/10 "2020-06-18T19:54:40Z")

</div>

No, that is not what this forum is here for. We are here to help, guide and even further teach coding techniques. As per the Welcome topic at the top of the forum, posting solutions is not allowed:

- You may not post solutions. It is strongly against the rule and might result in a mute or ban.

---

<div class="post-metadata">

**Author:** ![Chihya\_957](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chihya_957/32/12811_2.png) [@Chihya\_957](https://discourse.codecombat.com/u/Chihya_957)\
**Post date:** [June 18, 2020, 7:55pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/11 "2020-06-18T19:55:34Z")

</div>

OK SORRY I think I got an answer

---

<div class="post-metadata">

**Author:** ![Oliver\_Davidson](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/oliver_davidson/32/22361_2.png) [@Oliver\_Davidson](https://discourse.codecombat.com/u/Oliver_Davidson)\
**Post date:** [June 18, 2020, 10:09pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/12 "2020-06-18T22:09:59Z")

</div>

I only see… one if statement.

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 18, 2020, 10:27pm UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/13 "2020-06-18T22:27:23Z")

</div>

Of course, that is the ‘Restart’ code…what you get when you first visit the level, or restart it.

---

<div class="post-metadata">

**Author:** ![YoYo99](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/yoyo99/32/27784_2.png) [@YoYo99](https://discourse.codecombat.com/u/YoYo99)\
**Post date:** [February 9, 2022, 2:03am UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/14 "2022-02-09T02:03:44Z")

</div>

I do NOT get any of this at all!!!

---

<div class="post-metadata">

**Author:** ![YoYo99](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/yoyo99/32/27784_2.png) [@YoYo99](https://discourse.codecombat.com/u/YoYo99)\
**Post date:** [February 9, 2022, 2:04am UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/15 "2022-02-09T02:04:43Z")

</div>

7:30-8:00 I will be here

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [February 9, 2022, 8:07am UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/16 "2022-02-09T08:07:24Z")

</div>

Welcome to the forum @YoYo99🥳 This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the [guidelines](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601) if you haven’t yet. Have a great time!

Please post your code so we can help you, an don’t forget to format it using this button:

 ![Screenshot 2021-08-24 12.35.14](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/3/c/3c215fa51daac29c4dee042c92f597e6b9a39662.png)

---

<div class="post-metadata">

**Author:** ![YoYo99](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/yoyo99/32/27784_2.png) [@YoYo99](https://discourse.codecombat.com/u/YoYo99)\
**Post date:** [February 10, 2022, 1:58am UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/17 "2022-02-10T01:58:56Z")

</div>

All right I’m here now, sending my work…

---

<div class="post-metadata">

**Author:** ![YoYo99](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/yoyo99/32/27784_2.png) [@YoYo99](https://discourse.codecombat.com/u/YoYo99)\
**Post date:** [February 10, 2022, 2:00am UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/18 "2022-02-10T02:00:49Z")

</div>

```python
# 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 secretC:
    hero.moveXY(32, 33)
else:
    hero.moveXY(32, 15)
hero.moveXY(38, 24)
# If secretB is NOT true, take the high path.
if SecretC:
    hero.moveXY(44, 33)
else:
    hero.moveXY(44, 15)
hero.moveXY(50, 24)

```

---

<div class="post-metadata">

**Author:** ![YoYo99](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/yoyo99/32/27784_2.png) [@YoYo99](https://discourse.codecombat.com/u/YoYo99)\
**Post date:** [February 10, 2022, 2:04am UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/19 "2022-02-10T02:04:29Z")

</div>

Please Help me @Aya 🙏

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [February 10, 2022, 4:54am UTC](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349/20 "2022-02-10T04:54:06Z")

</div>

> [@YoYo99](#):
>
> ```python
> # If EITHER secretA or secretB is true, take the high path.
> if secretC:
> 
> ```

so here, you cannot use `secretC` again because it is **BOTH** `secretA` _ **and** _ `secretB`  
they are asking you for “or” so you can either make a new variable and assign it to `secretA or secretB` or you can just put it directly in the if-statement.

> [@YoYo99](#):
>
> ```python
> # If secretB is NOT true, take the high path.
> if SecretC:
> 
> ```

same goes for here, they are asking you if `secretB` is NOT TRUE or basically False. So again, instead of secretC, you can make a variable having the value of `not secretB` or directly putting it in the if-statement

[Next page](https://discourse.codecombat.com/t/how-to-beat-logical-path/22349.md?page=2)
