'Collect user input to determine size of rectangle in Turtle

We were asked to create a function draw_rectangle() with 4 parameters that when called forms a rectangle. I tried writing a code but when I run it, an error comes up for the 'turtle.goto(x,y)' saying its a string or something, here is the code:

import turtle 

def draw_rectangle(x, y, width, height):
  turtle.up()
  turtle.goto(x, y)
  turtle.down()
  turtle.forward(width)          
  turtle.left(90)
  turtle.forward(height)
  turtle.left(90)
  turtle.forward(width)
  turtle.left(90)
  turtle.forward(height)
  turtle.left(90)


x = print(input("Enter x"))
y = print(input("Enter y"))
width = print(input("Enter width"))
height = print(input("Enter height"))
print(draw_rectangle(x, y, width, height))


Solution 1:[1]

This doesn't answer the question but you could use:

    for side in range(2)
         turtle.forward(100)
         turtle.right(90)
         turtle.forward(50)
         turtle.right(90)

and also if you do:

    from turtle import *

you won't have to write

    turtle.forward()

just

    forward()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Terry Full