0
why is this code not running
import turtle # Create a turtle object t = turtle.Turtle() # Draw a square shape for i in range(4): t.forward(100) t.right(90) # Exit the turtle window turtle.done()
5 Answers
+ 4
Runs like a charm
See line 16ff in html
https://code.sololearn.com/WFNiN9O218sI/?ref=app
+ 6
Sololearn does not support turtle module by default
+ 1
you can use
__import__("os").system("pip -qqq install turtle")
to install turtle,
but because tkinter does not work on sololearn, you will get error below even after you have turtle installed.
import turtle
# import turtle
File "../Playground//turtle.py", line 107, in <module>
import tkinter as TK
File "../Playground//tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
+ 1
Oma Falk
Skulpt
So cool!
+ 1
Oma Falk
have to add this line
wn = turtle.Screen()
to call wn.exitonclick()