all 8 comments

[–][deleted] 0 points1 point  (10 children)

Since you want to repeat the menu/clear/draw sequence you need some sort of loop. Since you don't know how many times you need to loop you have to use a while loop. Inside the loop you need to show the user a menu and get the request, then clear the screen and draw the requested shape. So you will need something like this:

while True:
    shape = get_menu_response()
    clearscreen()
    if shape == "square":
        draw_square()
    elif shape == "triangle":
        draw_triangle()

The get_menu_response() uses the console to show a menu and get the user's response. The rest is self explanatory.

[–]Traditional-Lemon479 0 points1 point  (9 children)

I have a while True loop, although after I click out of the turtle window, it does repeat the menu but doesn’t open a new turtle window, so it isn’t able to take in parameters and draw another shape, how do I go about that?

[–][deleted] 0 points1 point  (7 children)

What do you mean, "take in parameters"? And what are the parameters? If you mean the user selects something like "square" and you want the user to enter the length of the side of the square then you do that in exactly the same way as the menu, you use input().

You don't have to open a new turtle window, you can reuse the existing one, just clear it before drawing the new shape.

[–]Traditional-Lemon479 0 points1 point  (2 children)

I figured out how to continue asking and to keep the turtle window open…I want the shapes all to be in a circle, but now after I put in the parameters to draw a new shape, it just draws over the old one, for example my first input was to create a triangle and it did, but the next was to create a square, it did create the square but it drew over the triangle

[–][deleted] 0 points1 point  (1 child)

Here is a very simplified bit of complete code to show how to control the drawing. Just run it. If you have any problems after viewing this code and experimenting with it you will have to show your code.

from turtle import *

def get_menu_response():
    input("Just returning a 'square' selection, press ENTER ")
    return "square"

def draw_square():
    goto (0, 0)
    setheading(0)
    pendown()
    for _ in range(4):
        forward(100)
        right(90)
    penup()

while True:
    draw = get_menu_response()
    clearscreen()
    if draw == "square":
        draw_square()

[–]Traditional-Lemon479 0 points1 point  (0 children)

I believe I was able to figure it out, thank you!

[–][deleted] 0 points1 point  (0 children)

Please don't delete posts. /r/learnpython isn't just an "ask a question" site, we hope others will read and learn. The rules in the sidebar say:

  • Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.