我星期五有作业,但我有一个问题,我的老师没有回复我,所以你能帮我吗?
我刚在学校开始使用 python turtle,这是我写的代码
from turtle import*
def square(square_color, length):
pd()
color(square_color)
begin_fill
for i in range(4):
fd(length)
lt(90)
end_fill()
pu()
fd(length)
speed(0)
n= int(input("Enter a number:"))
pu()
bk(n*25)
pu()
bk(n*25)
for cur_square in range(n):
if cur_square % 2 ==0:
square("black", 50)
if cur_square % 2 ==1:
square("red", 50)
if cur_square % 2 ==2:
square("gray", 50)
def draw_row(rows, length, square1_color, square2_color, cur_square):
for i in range(rows):
if(cur_square + i)% 2 ==0:
square(square1_color, length)
if (cur_square + i )%2 ==1:
square(square2_color, length)
def move_up(rows, length):
lt(90)
fd(length)
rt(90)
bk(rows*length)
length = int(input("The length of one square: "))
rows = int(input("The total amount of rows:"))
color1 = input("Color of the first square:")
color2 = input("Color of the second square:")
color3 = input("Color of the third square:")
speed(0)
pu()
setpos(-rows/2 * length, -rows/2 * length)
for cur_square in range(rows):
draw_row(rows, length, color1, color2, color3, cur_square)
move_up(rows,length)
它告诉我我有一个错误 - TypeError: draw_row() 在第 55 行正好采用 5 个参数(给定 6 个)
我应该怎么办?
我有错误的确切行
for cur_square in range(rows):
draw_row(rows, length, color1, color2, color3, cur_square)
move_up(rows,length)