# [SOLVED] Difficulty with Either/Or statements in level Logical Path

I don’t understand how Either/Or statements work, especially in the level Logical Path.

Hi @Michael_Joseph, I don’t exactly understand what you mean.
Are you talking about if, elif and else? Please could you post your code, formatted as it says here:

So I can see what’s going wrong.
Danny

2 Likes
``````type or paste code here
```# 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.
secretD = secretA or secretB
if secretD:
hero.moveXY(38, 24)
else:
# If secretB is NOT true, take the high path.
if secretB is not True:
hero.moveXY(50, 24)``````

You haven’t quite done this right. You should do each secret like they did the first one.
if secret:
move somewhere
else:
move somewhere else
move back to middle

You’ve only used the middle position when you should have two possible places (high and low) to move to first, then you move back to the middle (38, 24) and (50, 24).
I think you can do if secretB is not True:, but you can also do if not secretB:
Danny

Should be

``````secretC
``````

So this is asking if either secretA or secretB is true, take the high path, otherwise, take the low path. So the else should be your hero moving to the low path.

I don’t know how to write that. Every time I try doing that, a bug warning pops up.

Can you show me a screenshot of your bug?
Lydia

How do you take a screenshot on a laptop?

Are you on pc?
If so, you can press Windows Key + Shift + S and then drag the mouse to capture the area where you want to capture. Then Ctrl + V to paste it into the reply box.
If you’re on Mac, try googling it.
Lydia

This one is better…

Lydia

``````# 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)
hero.moveXY(32, 15)
# If EITHER secretA or secretB is true, take the high path.
secretC = secretA or secretB
if secretC is True:
hero.moveXY(32, 33)
else:
# If secretB is NOT true, take the high path.
if secretB is not True:
hero.moveXY(50, 24)

``````

Ok, you’ve got a bit confused. What you’re supposed to do is pretty much use the exact same format as the first bit of code that they wrote for you:

You have to do that again with the other two statements. Make two more variables, and use the moveXY they give you to move back to the middle (remember you can hover your mouse over the level screen to get a coordinate). Then put if yourVariable: move up, else: move down.
Literally copy the first section and put in or instead of and and use not for the last one.
Danny

I suggest you reload because I do not see the example code anywhere, you’ll need the example code for this level.
Lydia

What variables do I need to create?

These three.
Lydia
(how is this not 20 chars?)

You want to create three new variables. Defined by what Lydia said.
So for example:
secretC = secretA and secretB
You have to remember that each variable contains a “boolean” value. That is either True of False. And if you use the python “and”, it will make secret C also a boolean. What secretC contains depends on what secretA and secretB are. So if both secretA and secretB are True, the secretC is True. Otherwise, one, or both of them will be false and so secretC will also be false.
I hope that helped you understand it a bit more.
Danny

2 Likes

This is still incredibly difficult for me to figure out.

``````# 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 EITHER secretA or secretB are True:

``````

I am back to this frustrating level again.