Stopping a turtle when it reaches a point, Python
Question: I am currently in a beginning programming class, and I am blowing through the
assignments. Right now, I have to make 3 houses with the module turtle (which
I accomplished):

    
    
    def drawBody(mover):
        #Rectangle part
        mover.fillcolor("blue")
        mover.begin_fill()
        for i in range(2):
            mover.forward(100)
            mover.right(90)
            mover.forward(75)
            mover.right(90)
        mover.end_fill()
    
    
        #Triangle part
        mover.fillcolor("red")
        mover.begin_fill()
        mover.left(45)
        for i in range(2):
            mover.forward(70.5)
            mover.right(90)
        mover.right(45)
        mover.forward(100)
        mover.end_fill()
    
    
    
    
    
    
    
    #Create preproduction turtle
    import turtle
    wn = turtle.Screen()
    josh = turtle.Turtle()
    
    
    pointGoTo = -175
    for houses in range(3):
        josh.penup()
        josh.goto(pointGoTo,0)
        josh.pendown()
    
        drawBody(josh)
    
    
        josh.right(180)
        pointGoTo = pointGoTo + 125
    
    wn.exitonclick()
    

here is the while code. So I want the turtle to stop at a certain point, The
top left corner of the red square. I have tried multiple points but the while
just doesnt break/stop. Is my syntax off? or am I approaching this whole line
of the house thing all wrong? If i am being vague, please ask what you dont
understand, I really want to figure this out, but i am all out of ideas.:

    
    
    def drawBody(mover):
        #Rectangle part
        mover.fillcolor("blue")
        mover.begin_fill()
        for i in range(2):
            mover.forward(100)
            mover.right(90)
            mover.forward(75)
            mover.right(90)
        mover.end_fill()
    
    
        #Triangle part
        mover.fillcolor("red")
        mover.begin_fill()
        mover.left(45)
        for i in range(2):
            mover.forward(70.5)
            mover.right(90)
        mover.right(45)
        mover.forward(100)
        mover.end_fill()
    
        mover.left(90)
        mover.forward(75)
        mover.left(90)
        n = mover.position()
        print(n)
        while True:
            mover.forward(100)
            n = mover.position()
            print(n)
            mover.left(90)
            mover.forward(5)
            mover.left(90)
            n = mover.position()
            print(n)
            mover.forward(100)
            mover.right(90)
            mover.forward(5)
            mover.right(90)
    
    
            if n == (-75.30,0.00):
                break
    
    
    
    
    
    
    
    #Create preproduction turtle
    import turtle
    wn = turtle.Screen()
    josh = turtle.Turtle()
    
    
    pointGoTo = -175
    for houses in range(3):
        josh.penup()
        josh.goto(pointGoTo,0)
        josh.pendown()
    
        drawBody(josh)
    
    
        josh.right(180)
        pointGoTo = pointGoTo + 125
    
    wn.exitonclick()
    


Answer: first of all, you're checking in the wrong place, you ahve to check it here:

    
    
    while True:
        mover.forward(100)
    
        mover.left(90)
        mover.forward(5)
        mover.left(90)
        n = mover.position()
    
        if abs(n - (-75.30, 0.00)) < 0.01:
            break
    
        mover.forward(100)
        mover.right(90)
        mover.forward(5)
        mover.right(90)
    

Your check is not succesfull because n is actually
[turtle.Vec2D](http://docs.python.org/2/library/turtle.html#turtle.Vec2D), and
coordinates are float, you can see it if you do `print n[0], n[1]`. There're
many links on SO about comparing floats, like [Floating point equality in
python](http://stackoverflow.com/questions/4028889/floating-point-equality-in-
python), for example. In your case you can do:

    
    
    if abs(n - (-75.30, 0.00)) < 0.01:
        break
    

But I think, the best way for you would be to just paint fixed amount of
times:

    
    
    mover.left(90)
    mover.forward(70)
    mover.left(90)
    for i in xrange(7):
        mover.forward(100)
        mover.left(90)
        mover.forward(5)
        mover.left(90)
    
        mover.forward(100)
        mover.right(90)
        mover.forward(5)
        mover.right(90)
    

Also you have to change your code like this:

    
    
    for houses in range(3):
        josh.penup()
        josh.goto(pointGoTo,0)
        josh.pendown()
    
        drawBody(josh)
    
        pointGoTo = pointGoTo + 125
    

