我想用乌龟中的数组填充不同颜色的圆 python

I want to fill circles with different colors using array in turtle python

我为每个圆圈使用硬编码制作了 4 个这样的圆圈,但效率不高。

这是我的代码,但我不知道如何访问颜色数组和坐标 x 和 y 数组,以便可以通过所有索引访问它。

from turtle import *
setup()
title('4 CIRCLES')

col = ['yellow', 'green', 'blue', 'red']
x = [100,65,30,5]
y = [100,65,30,5]

def lingkaran(number, rad = 50) :
    for cir in range(number) :
        penup()
        goto(x, y)
        pendown()
        color(col)
        begin_fill()
        circle(rad)
        end_fill()
        lingkaran(4)

hideturtle()
done()

我想通过访问数组来简化它,希望有人能提供帮助。 谢谢

由于我们正在查看圆之间的固定距离,因此我会抛出坐标数组以支持起始位置和偏移量。然后我会简单地循环颜色数组:

from turtle import *

title('4 CIRCLES')

COLORS = ['yellow', 'green', 'blue', 'red']

def lingkaran(colors, position, offset, radius, pen_width=3):
    width(pen_width)

    for color in colors:
        penup()
        goto(position)
        pendown()

        fillcolor(color)
        begin_fill()
        circle(radius)
        end_fill()

        position += offset

lingkaran(COLORS, Vec2D(-100, 100), Vec2D(35, -35), 50)

hideturtle()
done()

但是有很多方法可以解决这样的问题。