Why doesn’t this code work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Why doesn’t this code work?

import turtle from turtle import * turtle.title("rainbow spiral") speed(15) bgcolor("black") r,g,b=255,0,0 for i in range(255*2): colormode(255) if i<255//3: g+=3 elif i<255*2//3: r-=3 elif i<255: b+=3 elif i<255*4//3: g-=3 elif i<255*5//3: r+=3 else: b-=3 fd(50+i) rt(91) pencolor(r,g,b) done()

9th Jun 2022, 4:38 PM
Mrgoodatcode
Mrgoodatcode - avatar
18 Answers
+ 3
Do you have an error when you run the code or is it not drawing the shape you are expecting, please add more details. What are you trying to draw?
9th Jun 2022, 5:05 PM
Apollo-Roboto
Apollo-Roboto - avatar
+ 2
turtle just doesnt work in sololearn sorry bud..
9th Jun 2022, 5:42 PM
dutch guy
dutch guy - avatar
+ 2
dawit belachew , try this in my code. import turtle t=turtle.Turtle() s=turtle.Screen() t.speed(10) # not 100 max = 0 s.bgcolor("black") #debug for i in range(240): t.color("yellow") t.circle(i) t.left(5) t.done() #debug
10th Jun 2022, 11:27 PM
Solo
Solo - avatar
+ 1
Run my code, double click on the "code" button and paste your code with my corrections into the field ☺️ from turtle import Turtle, Screen Screen().setup(360,360) Screen().bgcolor("black") turtle = Turtle() turtle.shape("turtle") turtle.speed(15) r,g,b=255,0,0 for i in range(255*2): turtle.color("red") if i<255//3: g+=3 elif i<255*2//3: r-=3 elif i<255: b+=3 elif i<255*4//3: g-=3 elif i<255*5//3: r+=3 else: b-=3 turtle.forward(50+i) turtle.right(91) turtle.pencolor(r,g,b) turtle.done() https://code.sololearn.com/WpuWX7fi9doO/?ref=app https://www.sololearn.com/post/1469146/?ref=app
9th Jun 2022, 7:11 PM
Solo
Solo - avatar
0
Im trying to draw a rainbow spiral
9th Jun 2022, 5:06 PM
Mrgoodatcode
Mrgoodatcode - avatar
0
What does it work on dutch guy?
9th Jun 2022, 5:44 PM
Mrgoodatcode
Mrgoodatcode - avatar
0
i have an app called pydroid 3 and it works on that so ye
9th Jun 2022, 5:45 PM
dutch guy
dutch guy - avatar
0
The app doesnt show on mobile
9th Jun 2022, 5:46 PM
Mrgoodatcode
Mrgoodatcode - avatar
0
do you have an apple phone bc i have an samsung so maybe its bc of that
9th Jun 2022, 5:48 PM
dutch guy
dutch guy - avatar
0
Yes
9th Jun 2022, 5:48 PM
Mrgoodatcode
Mrgoodatcode - avatar
0
I have a desktop too
9th Jun 2022, 5:48 PM
Mrgoodatcode
Mrgoodatcode - avatar
0
oh on desktop its visual studio code, the python ide and any other
9th Jun 2022, 5:49 PM
dutch guy
dutch guy - avatar
0
import turtle t=turtle.Turtle() t.speed(100) turtle.bgcolor("black") for i in range(240): t.color("yellow") t.circle(i) t.left(5) turtle.done This code isn't working for me Python
10th Jun 2022, 10:50 PM
dawit belachew
dawit belachew - avatar
0
Turtles don't work..... dk abt others...bit not working fr me...
11th Jun 2022, 5:49 AM
Sharon Christina
Sharon Christina - avatar
0
Okay I will
16th Jun 2022, 6:31 PM
dawit belachew
dawit belachew - avatar
0
I tried it but it doesn’t work
16th Jun 2022, 6:33 PM
dawit belachew
dawit belachew - avatar
0
It says there is a problem in the line 3 the import turtle command
16th Jun 2022, 6:34 PM
dawit belachew
dawit belachew - avatar
0
dawit belachew, I don't know what you are doing, but your code with my fixes works fine in my "turtle Heart" code.
16th Jun 2022, 11:41 PM
Solo
Solo - avatar