Python Forum

Full Version: Collision function problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am writing python code inside Turtle import. I am making a program where one turtle chases another turtle. I want my Turtle player to change colors if the other turtle catches up to him. Right now I have created a function:
def collision_decision():
    if chaser.pos() = player.pos():
        player.color("orange","green")
    else:
I am trying to set it so that when both turtles have the same position (when the chaser turtle has caught up with the player) that my player turtle changes colors. However, now my code won't run and it says it doesn't recognize the line "if chaser.pos() = player.pos():"

Any advice you could give would be appreciated. If you would like the whole code I can give it. Just let me know.
There is a difference between "=" and "==" Note also that the x coordinates of whatever figure you are using, can catch the other figure while the y coordinates are different, higher or lower, and vice versa.
I don't know if this will help you, but you need to change = to ==. = is an assignment operation in Python.