turtle.width() function in Python
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
turtle.width()
This method is used to set or return the line thickness. Set the line thickness to width or return it. If resizemode is set to “auto” and turtleshape is a polygon, that polygon is drawn with the same line thickness. If no argument is given, the current pensize is returned.
Syntax :
turtle.width(width=None) turtle.pensize(width=None)
Note: This method has Aliases: pensize and width and requires only one argument “width — positive number”.
Below is the implementation of the above method with some examples :
Example 1 :
Python3
# import package import turtle # forward turtle by 100 turtle.forward( 100 ) # set turtle width to 4 turtle.width( 4 ) # forward turtle by 100 # in right direction turtle.right( 90 ) turtle.forward( 100 ) |
Output :

Example 2 :
Python3
# import package import turtle # loop for pattern for i in range ( 15 ): # set turtle width turtle.width( 15 - i) # motion for pattern turtle.forward( 50 + 15 * i) turtle.right( 90 ) |
Output :

In this above example, we decrease the size of the turtle at every move so the size of the line of the outer lines is smaller than that of the inner lines.