I don t want to seem like a begger but I ve been working on this code for the past 3 days and made 0 progress

+2 votes

Basically, my code runs a turtle and asks the user for measurements of the lengths for the shape. I just need to know why it isn't working. You can run it on Python to see exactly what I mean.

import turtle
import tkinter as tk
quest = None
Input = None
w = None
s = None
a = None
d = None
def forward():
    t.forward(w)
def back():
    t.back(s)
def left():
    t.left(a)
def right():
    t.right(d)

def whaat():
            global quest
            global w
            global s
            global a
            global d
            print('What would you like to set?')
            what = input('Would you like to set forward, back, left, or right?: ')
            if what == 'forward' or what == 'FORWARD' or what == 'Forward':
                w = input('How FAR would you like ''Turtle'' to move (forward): ')
                w = int(w)
                quest = input('Would you like to Set Anything Else? (y or n): ')
                if quest == 'y' or quest == 'yes' or quest == "YES":
                    whaat()
                else:
                    root = tk.Tk()
                    canvas = tk.Canvas(master = root, width = 500, height = 500)
                    canvas.pack()

                    t = turtle.RawTurtle(canvas)

                    tk.Button(master = root, text = "Forward", command = forward).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Back", command = back).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Left", command = left).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Right", command = right).pack(side
                                                             = tk.LEFT)
                    root.mainloop()
                    
            elif what == 'back' or what == 'BACK' or what == 'Back':
                s = input('How FAR would you like ''Turtle'' to move (back): ')
                s = int(s)
                quest = input('Would you like to Set Anything Else? (y or n): ')
                if quest == 'y' or quest == 'yes' or quest == "YES":
                    whaat()
                else:
                    root = tk.Tk()
                    canvas = tk.Canvas(master = root, width = 500, height = 500)
                    canvas.pack()

                    t = turtle.RawTurtle(canvas)

                    tk.Button(master = root, text = "Forward", command = forward).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Back", command = back).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Left", command = left).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Right", command = right).pack(side
                                                             = tk.LEFT)
                    root.mainloop()

            elif what == 'left' or what == 'LEFT' or what == 'Left':
                a = input('What ANGLE would you like ''Turtle'' to move (left): ')
                a = int(a)
                quest = input('Would you like to Set Anything Else? (y or n): ')
                if quest == 'y' or quest == 'yes' or quest == "YES":
                    whaat()
                else:
                    root = tk.Tk()
                    canvas = tk.Canvas(master = root, width = 500, height = 500)
                    canvas.pack()

                    t = turtle.RawTurtle(canvas)

                    tk.Button(master = root, text = "Forward", command = forward).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Back", command = back).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Left", command = left).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Right", command = right).pack(side
                                                             = tk.LEFT)
                    root.mainloop()

            elif what == 'right' or what == 'RIGHT' or what == 'Right':
                d = input('What ANGLE would you like ''Turtle'' to move (right): ')
                d = int(d)
                quest = input('Would you like to Set Anything Else? (y or n): ')
                if quest == 'y' or quest == 'yes' or quest == "YES":
                    whaat()
                else:
                    root = tk.Tk()
                    canvas = tk.Canvas(master = root, width = 500, height = 500)
                    canvas.pack()

                    t = turtle.RawTurtle(canvas)

                    tk.Button(master = root, text = "Forward", command = forward).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Back", command = back).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Left", command = left).pack(side
                                                             = tk.LEFT)
                    tk.Button(master = root, text = "Right", command = right).pack(side
                                                             = tk.LEFT)
                    root.mainloop()
            else:
                print('Incorrect Statement, Please Try Again')
                whaat()

def which():
    global Input
    global w
    global s
    global a
    global d
    Input = input('Would you like to set your buttons?: ')
    if Input == 'y' or Input == 'yes' or Input == 'YES' or Input == 'Yes':
        whaat()
    elif Input == 'n' or Input == 'no' or Input ==  'NO' or Input == 'No':
        w = 100
        s = 100
        a = 90
        d = 90
        root = tk.Tk()
        canvas = tk.Canvas(master = root, width = 500, height = 500)
        canvas.pack()

        t = turtle.RawTurtle(canvas)

        tk.Button(master = root, text = "Forward", command = forward).pack(side
                                                             = tk.LEFT)
        tk.Button(master = root, text = "Back", command = back).pack(side
                                                             = tk.LEFT)
        tk.Button(master = root, text = "Left", command = left).pack(side
                                                             = tk.LEFT)
        tk.Button(master = root, text = "Right", command = right).pack(side
                                                             = tk.LEFT)
        root.mainloop()
    else:
        print('Incorrect Statement, Please Try Again')
        which()

which()

Thanks a lot for helping, it really is appreciated!

Nov 26, 2019 in Python by Kyler
• 140 points
892 views
Hi @Kyler, Can you please explain a little about what output you are expecting?
Hi @Kyler,

I executed your code with one minor change. I used 't' as a global variable. The code ran without errors. What do you mean by "it's not working"? Do you want the line to disappear on back? Are you talking about the issue that the arrow turns with its top as the axis? What exactly are you looking for?

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

I've been trying to run this code, but the error says "Expected an indented block" for the line, " word_as_list[index] = guess."

Hi, @Paradox, The error message IndentationError: expected an indented ...READ MORE

answered Nov 21, 2020 in Python by anonymous
• 65,770 points
1,087 views
+7 votes
2 answers

I want to build a recommender system incorporating diversity and accuracy in the recommender engine.

I dont know what exactly you are ...READ MORE

answered Sep 24, 2018 in Python by slayer
• 29,370 points
2,125 views
0 votes
1 answer
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,443 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,078 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP