while True:
Move to the X only if shouldRun() returns True
if shouldRun() return true:
hero.moveXY(75, 37)
Else, attack!
the if shouldRun statement is saying that it needs another colon at the end but I did that then it says it still needs another one. please help!!!
Could you format your code property using the button </> so we ca help you?
def shouldRun():
if hero.health < hero.maxHealth / 2:
return True
else:
return False
while True:
# Move to the X only if shouldRun() returns True
if shouldRun() return true:
hero.moveXY(75, 37)
# Else, attack!
this is my code and it keeps saying that it needs an extra colon after
if shouldRun() return true:
and I can’t figure it out. Can you please help?
After this, put
enemy = hero.findNearestEnemy()
hero.attack(enemy)
I put the code there and it is still saying that it needs an extra colon after
if shouldRun() return true:
Instead of this, try to write something like this:
run = shouldRun()
if run:
#here put the moveXY command
thanks for the solution it worked