[SOLVED][Logical Path] Why hero won't move to specified place?


#1

Hi, there.
It seems compiler ignore line 16 and 17. How can I make hero to move (32, 33) ?

# Get two secret true/false values from the wizard.
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.
# Check the guide for notes on how to write logical expressions.
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 = True or secretB = True:
    hero.moveXY(32, 33)  

# If secretB is NOT true, take the high path.
if secretB != True:
    hero.moveXY(44, 33)  
hero.moveXY(50, 24)

#2

one = is for assignment.
two == is for comparison.


#3

Hi,
Sorry, I pasted wrong code. I have pasted my correct code.
This cord do not work.

# Get two secret true/false values from the wizard.
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.
# Check the guide for notes on how to write logical expressions.
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 == True or secretB == True:
    hero.moveXY(32, 33)  

# If secretB is NOT true, take the high path.
if secretB != True:
    hero.moveXY(44, 33)  
hero.moveXY(50, 24)

#4

Use:

if secretA or secretB:
    hero.moveXY(32,33)

and

if not secretB:
    hero.moveXY(44,33)

instead of what you wrote


#5

Ah wait. I found out the problem:
you didn’t add an else for the

if not secretB

#6

Hi. Thank your reply.
But still the mission failed.

# Get two secret true/false values from the wizard.
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.
# Check the guide for notes on how to write logical expressions.
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 or secretB:
    hero.moveXY(32, 33)  

# If secretB is NOT true, take the high path.
if not secretB :
    hero.moveXY(44, 33)  
hero.moveXY(50, 24)

#7

So then put an else: and go to the lower path


#8

I understood what is my mistake. Thank you.