-6

I'm running this in python 3 and it keeps telling me there's a traceback. elif is a syntax error. I've tried to troubleshoot but I just can't fix it. When helping me could you please fix the code directly since i'm not good with implementing foreign code. It's meant to return back the please select your conversion if the following options are not selected but obviously not working. Thank You!

from turtle import Screen, Turtle

print("Please select your conversion:")

invalid_input = True
def Converter() :
  conversion = input ("metric to metric type mm, metric to imperial type mi, units of water type w, for physics equations type p, for math equations type m and for quick facts type q:")
  print("Please select your conversion:")

  if conversion == "mm":
    #selection = "metric to metric conversions!"

  elif conversion == "mi":
    selection = "metric to imperial conversions!"
    invalid_input = False
  elif conversion == "w":
    selection = "water conversions!"
    invalid_input = False
  elif conversion == "p":
    selection = "physics equations!"
    invalid_input = False
  elif conversion == "m":
    selection = "maths equations!"
    invalid_input = False
  elif conversion == "q":
    selection = "quick facts!"
    invalid_input = False
  else:
    print("\n")
    print("Invalid! Please try again.\n \n \n")
while invalid_input : 


print("\n")
print("You have selected", selection + "!")

invalid_input = True
def start() :
  decision = input ("Is this correct? If correct type y, if incorrect type n.")
  if decision == "y":
        #stuff
        invalid_input = False
while invalid_input : # this will loop until invalid_input is set to be True
    start()
martineau
  • 119,623
  • 25
  • 170
  • 301
Nour Alaas
  • 11
  • 6
  • Can you please add in the stacktrace? Or perhaps even a link to something like a repl or fiddle with your code? – Dakota Maker Nov 20 '18 at 21:46
  • You have commented the only statement `selection ...` below the `if` statement - it needs at least `pass` below it – DisappointedByUnaccountableMod Nov 20 '18 at 21:48
  • Once you get the syntax issue figured-out, I suggest you read [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response). – martineau Nov 20 '18 at 21:57
  • @DakotaMaker https://repl.it/@15nalaas/Science-Converter-11?language=python3 – Nour Alaas Nov 20 '18 at 21:59

1 Answers1

2

Python expects some code (at least one line) inside your conditionals. If you don't have anything to put right now, you can put pass:

if conversion == "mm":
    #selection = "metric to metric conversions!"
    pass
elif conversion == "mi":
    #selection = "metric to imperial conversions!"
    pass
elif conversion == "w":
    #selection = "water conversions!"
    pass
elif conversion == "p":
    #selection = "physics equations!"
    pass
elif conversion == "m":
    #selection = "maths equations!"
    pass
elif conversion == "q":
    #selection = "quick facts!"
    pass
Aurora Wang
  • 1,822
  • 14
  • 22