Python 乌龟 - turtle.begin_fill() 和 turtle.end_Fill() 出错
Python Turtle - Error with turtle.begin_fill() and turtle.end_Fill()
我在读高中计算机科学专业 class,我似乎找不到 turtle.begin_fill() 和 turtle.end_fill() 的正确 placement/usage为我正在绘制的形状着色。我试过移动这两个,但我不断收到此错误:
TypeError: begin_fill() takes 1 positional argument but 2 were given
这是我的代码:
side_number = int(input("How many sides should the polygon have?"))
side_length = int(input("How long should the sides be?"))
side_color = (input("What color should the sides be?"))
fill_color = (input("What color should fill the shape?"))
import turtle
wn = turtle.Screen()
john = turtle.Turtle()
john.color(side_color)
for i in range(side_number):
john.begin_fill(fill_color)
john.forward(side_length)
john.left(360/side_number)
john.end_fill(fill_color)
begin_fill
和 end_fill
不接受任何参数。您可以将填充颜色指定为 turtle.color
的第二个参数。此外,begin_fill
和 end_fill
应该在循环之外,因为它们应该为每个多边形调用一次而不是每行一次。
side_number = int(input("How many sides should the polygon have?"))
side_length = int(input("How long should the sides be?"))
side_color = (input("What color should the sides be?"))
fill_color = (input("What color should fill the shape?"))
import turtle
wn = turtle.Screen()
john = turtle.Turtle()
john.color(side_color, fill_color)
john.begin_fill()
for i in range(side_number):
john.forward(side_length)
john.left(360/side_number)
john.end_fill()
我在读高中计算机科学专业 class,我似乎找不到 turtle.begin_fill() 和 turtle.end_fill() 的正确 placement/usage为我正在绘制的形状着色。我试过移动这两个,但我不断收到此错误:
TypeError: begin_fill() takes 1 positional argument but 2 were given
这是我的代码:
side_number = int(input("How many sides should the polygon have?"))
side_length = int(input("How long should the sides be?"))
side_color = (input("What color should the sides be?"))
fill_color = (input("What color should fill the shape?"))
import turtle
wn = turtle.Screen()
john = turtle.Turtle()
john.color(side_color)
for i in range(side_number):
john.begin_fill(fill_color)
john.forward(side_length)
john.left(360/side_number)
john.end_fill(fill_color)
begin_fill
和 end_fill
不接受任何参数。您可以将填充颜色指定为 turtle.color
的第二个参数。此外,begin_fill
和 end_fill
应该在循环之外,因为它们应该为每个多边形调用一次而不是每行一次。
side_number = int(input("How many sides should the polygon have?"))
side_length = int(input("How long should the sides be?"))
side_color = (input("What color should the sides be?"))
fill_color = (input("What color should fill the shape?"))
import turtle
wn = turtle.Screen()
john = turtle.Turtle()
john.color(side_color, fill_color)
john.begin_fill()
for i in range(side_number):
john.forward(side_length)
john.left(360/side_number)
john.end_fill()