[Tutor] Polygon fill in turtle

Roger Lea Scherer rls4jc at gmail.com
Tue Mar 27 17:10:34 EDT 2018


I looked at Stackoverflow, followed, but could not succeed. I want to fill
the polygon with a different color than the pen color. When I print out the
filler it is the correct color, but the actual fill is not. Here it is:
(tada!)

# create a user-defined polygon
import turtle


wn = turtle.Screen()
hadir = turtle.Turtle()
hadir.speed(8)

sides = int(input("Please enter the number of sides of a polygon you want
drawn: "))
length = int(input("How long would you like each side? "))
outlineColor = input("What color would you like for the outline?")
filler = input("And what color would you like to fill it with? ")

hadir.begin_fill()
hadir.color(outlineColor)
print(filler)
for i in range(sides):
    hadir.forward(length)
    hadir.left(360 / sides)
    hadir.up()
hadir.end_fill()

Thanks, as always.

-- 
Roger Lea Scherer
623.255.7719


More information about the Tutor mailing list