turtle.write() not even writing in python[resolved]

258 Views Asked by At

The problem is that turtle.write() is simply not writing:

if year % 4 == 0:
        if year % 100 == 0:
            if year % 400 == 0:
                board.write("It is a leap year", font=("Verdana",\
                                    16, "normal"), move=True)
                return
            board.write("It is not a leap year", font=("Verdana",\
                                               16  1, "normal"))
            return
        board.write("It is a leap year", font=("Verdana",\
                                    16, "normal"), move=True, align="center")

Oh, and by the way, year is a pre-defined variable that is the year the user has entered: All I got is this:

year = int(textinput("LEAP YEAR CHECKER", "enter the year:"))

Python Turtle Graphic Window:

Python Turtle Graphic Window

I tried to write this. I even tried to use the Turtle() object. But, alas, nothing happened. What to do?

1

There are 1 best solutions below

0
AlmostUseless On

If I understand correctly, you want the turtle to write and that it shall appear on screen?

The following works for me:

from turtle import Turtle, Screen

ALIGNMENT = "Center"
FONT = ("Verdana", 16, "normal")
LEAP_YEAR = "It is a leap year"
COMMON_YEAR = "It is not a leap year"

year = int(input("LEAP YEAR CHECKER enter the year: "))

board = Turtle()
board.hideturtle()
board.color("black")
screen = Screen()

if year % 4 == 0:
    if year % 100 == 0:
        if year % 400 == 0:
            board.write(LEAP_YEAR, font=FONT, align=ALIGNMENT)
        else:
            board.write(COMMON_YEAR, font=FONT, align=ALIGNMENT)
    else:
        board.write(LEAP_YEAR, font=FONT, align=ALIGNMENT)
else:
    board.write(COMMON_YEAR, font=FONT, align=ALIGNMENT)

screen.exitonclick()