r/learnpython • u/PeakMedium • 3d ago
Help me troubleshoot?
Using https://pythonsandbox.com/turtle I've created this simple drawing app and it works. But when I try to save it I get a "The server returned a "405 Method Not Allowed"" error message. Tried multiple browsers, incognito mode, turned off extensions, multiple computers. No luck. Any suggestions?
import turtle
t = turtle.Turtle()
t.speed(5) # 1:slowest, 3:slow, 5:normal, 10:fast, 0:fastest
shape = "start"
while shape == "start":
shape = input("Would you like to start or stop drawing a square?")
if shape == "start":
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
elif shape == "stop":
break
3
u/zanfar 3d ago
Not a Python issue.
That's an HTTP error, the issue is with the configuration of the website you're using. Nothing we can do to help you.
1
u/lakseol 3d ago edited 3d ago
Your code doesn't show in my browser properly. This is what I think you have:
That works fine, as you said, but it can be improved. You have two tests of whether you should stop the loop, the top
whilecondition and the bottomelif shape == "stop":. You don't need two tests, you can use a simple loop (no test) and test immediately after theinput()statement. This gives you simpler code:You could have just made the loop
while True:and left thebreaktest where it was, but I think it's more readable to keep the the loop control stuff (the start of the loop and the test to exit) all close together.