r/learnpython • • 2d 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

1 Upvotes

7 comments sorted by

3

u/zanfar 2d 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/PeakMedium 1d ago

Thank you. If that's the case, why are the others in my class not having the same problem when they try to save? It's working fine for them.

1

u/zaphodikus 1d ago

Save your code first. Then reset all browser cookies and so on and log in and do over.

Its always a schoolday, CTRL+F5 is your friend, but beware, it's the mate of ALT+F4 .

2

u/Manostel-Jveive 1d ago

they can still just copy paste the code into a local .py file though, turtle comes built into the standard library anyway.

1

u/lakseol 2d ago edited 2d ago

Your code doesn't show in my browser properly. This is what I think you have:

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

That works fine, as you said, but it can be improved. You have two tests of whether you should stop the loop, the top while condition and the bottom elif shape == "stop":. You don't need two tests, you can use a simple loop (no test) and test immediately after the input() statement. This gives you simpler code:

import turtle

t = turtle.Turtle()
t.speed(5) # 1:slowest, 3:slow, 5:normal, 10:fast, 0:fastest

while True:
    shape = input("Would you like to start or stop drawing a square?")
    if shape == "stop":
        break

    t.forward(100)
    t.right(90)
    t.forward(100)
    t.right(90)
    t.forward(100)
    t.right(90)
    t.forward(100)

You could have just made the loop while True: and left the break test 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.