Mages might help

I can’t figure out what is wrong with my code, here it is:
hero.cast(“fire-ball”)
while True:
missile = hero.findMyMissiles
print(missile.pos.x)
if hero.color == “red” and missile.pos.x > 50:
break
elif hero.color == “blue” and missile.pos.x < 50:
break
print(“End of loop”)

I would appreciate it if you could figure out the problem with my code

Can you align your code properly, or paste in your code?

hero.cast("fire-ball")
while True:
    missile = hero.findMyMissiles
    print(missile.pos.x)
    if hero.color == "red" and missile.pos.x > 50:
        break
print("End of loop")

please past it in propper format by clicking the </> symbol when you type and post you code inside of it

2 Likes
hero.cast("fire-ball")
while True:
    missile = hero.findMyMissiles
    print(missile.pos.x)
    if hero.color == "red" and missile.pos.x > 50:
        break
print("End of loop")

much better! :+1: now we can understand your code better

You need parentheses for a function. Line three.

thanks, but it still says that the property of “x” is undefined

The missile might not exist at that time, so you will need to check to see if the missile exists.

it is still saying it can’t read the property of x for some reason for

print(missile.pos.x)
hero.cast("fire-ball")
while True:
    missile = hero.findMyMissiles()
    if missile:
        print(missile.pos.x)
        if hero.color == "red" and missile.pos.x > 50:
            break
print("End of loop")

hero.cast(“fire-ball”)
while True:
missile = hero.findMyMissiles()
if missile:
print(missile.pos.x)
if hero.color == “red” and missile.pos.x > 50:
break
print(“End of loop”)

you have a missing comma at hero.cast("fire-ball’);

sorry it’s not a comma

my code is telling me that the property of “x” is undefined