Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some help
#1
I am trying to create a little option for my script and found something online but it is not working:
 def path() :
    print ("1.Turn left")
    print ("2. Turn right")
    path = str(input("Which way do you choose to turn? "))
if path == "left":
    left1()
elif path == "right":
    right1()
else:
    path()
def right() :
    print ("you went right...")
def left() :
    print ("you went left...") 
can anyone help me out?
Reply
#2
were ever you found it, its not good.
  • def path() has an indent that shouldn't be there
  • input returns a string it does not need str to be called on the result of input
  • function path is not called before the if
  • function path does not return anything
  • function path and variable name path clash
  • function left1 and right1 are not defined
  • if left1 was meant to call left and right1 was meant to call right, they are defined after they are called.
Reply
#3
Is there any way you can simplify this information? I have only been learning python for a couple of days now and a lot of this is quite confusing to me. Thanks anyway though.
Reply
#4
I also tried this that I made myseld but whenever I run it all I get is the "You come to a path..." and thats all...
import time
print("You come to a path...")
time.sleep(0.5)
def main1():
    path1a()

def path1a():
    print("You can either turn left or right...")
    turn1a = input("Which way do you want to go?... left/right ")
    if turn1a =="right":
        print("You turn right...")
        right1a()
    elif turn1a =="left":
        print("You turn left...")
        left1a()
    else:
        print("Please type left/right")
        path1a()
        
def right1a():
    print ("You have succesfully turned right")

def left1a():
    print ("You have succesfully turned left")
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020