Search code examples
pythoninputwindow

Asking for user to input screen size for a turtle project


I am brand new to Python and know very little. I am working on a project using turtles, where I need to ask the user to input the window width and height, but I am completely lost. I have come up with this so far.

w = int(input(w))
h = int(input(h))
screen = turtle.Screen()
screen.setup(w, h, 0, 0)

I have no idea what I'm doing wrong. Any help would be great. Thanks.


Solution

  • Looks like you were almost there!

    import turtle
    
    w = int(input("Enter Width: "))
    h = int(input("Enter Height: "))
    screen = turtle.Screen()
    screen.setup(w, h, 0, 0)
    

    It looks like you forgot to import the turtle library, in addition notice the input lines. If you only want the prompt to be w or h it would need to be enclosed with " "