Python Forum
Hello, can I have some help? (More below)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello, can I have some help? (More below)
#1
Hello, my code is duplicating. When I answer the first question, it does the start() again. I seriously can't figure out what I've done wrong! thank you!

answer_a = ["a", "A"]
answer_b = ["b", "B"]
answer_c = ["c", "C"]
answer_yes = ["Y", "y", "yes", "Yes"]
answer_no = ["N", "n", "no", "No"]

def start():
  print("""You wake up and find yourself hanging from a rope that is tied aroujnd your neck. what do you do? \nA. Start swinging \nB. Attempt to take it off \nC. Scream for help  """)
  choice = input(">>>")
  if choice in answer_a:
    option_swing()
  elif choice in answer_b:
    option_pull()
  elif choice in answer_c:
    option_scream()
  else:
    print("Please use A, B, or C. ")
  start()

def option_swing():
  print("You start swinging with the rope tied around your neck, you continue to swing until the rope snaps and you fall to the floor. You look around and there's one door, a drawer and a mirror, what do you do? \nA. Open the drawer \nB. Break the mirror and use the broken shards to cut open your wrists and bleed out \nC. Attempt the bust the door open")
choice1 = input(">>>")
if choice1 in answer_a:
  print("")

  def option_pull():
      print("You attempt to pull the rope off your neck, and struggle until your ")

def option_scream():
  print("scream")
Reply
#2
start() is called at the end of start(). So, once the if...else is done, it recursively calls start() again.
Reply


Forum Jump:

User Panel Messages

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