问题遇到的现象和发生背景
网上找的画彩虹,本人不是专业编程,多年一直在坚持学编程,10多年来一直坚持,还请看到帮忙看下,带一下
用代码块功能插入代码,请勿粘贴截图
import turtle
q = turtle.pen()
turtle.bgcolor('black')
sides = 7
colors = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple']
for x in range(360):
q.speed(35)
q.pencolor(colors([x % sides]))
q.forward(x * 3 / sides + x)
q.left(360 / sides + 1)
q.width(x * sides / 200)
运行结果及报错内容
C:\Users\admin\AppData\Local\Programs\Python\Python36\python.exe D:/Python/TestAPP/test彩虹.py
Traceback (most recent call last):
File "D:/Python/TestAPP/test彩虹.py", line 8, in
q.speed(35)
AttributeError: 'dict' object has no attribute 'speed'
Process finished with exit code 1
我的解答思路和尝试过的方法
尝试多次运行不出来
我想要达到的结果
需要运行结果