0

I am supposed to program a calculator that will calculate the amount that you should tip based on the quality of service received.

I keep getting errors at around line 12 that state that the 'elif' is an invalid syntax. I am not exactly sure what I am doing wrong, but then again, I do not know much in the first place.

I've been doing a lot of digging around on the internet to see what I could find to figure out what I am doing wrong, but I have not found it out, yet. (I've tried several variations of the code to see what might or might not work, but this is, essentially, what I have put together and have been working off of.)

def main () :
  print ("This program calculates tips based upon the")
  print ("quality of the service provided.")
  principal = float (input ("Enter the price of your meal: $") )
  service = (input ("Enter whether your service was Poor, Average, or Excellent: "))
  Exceltip=(principal*1.2)
  avgtip=(principal*1.15)
  poortip=(principal*1.1)
  if service == Excellent or excellent:
    print("Tip = ", Exceltip)
    print("The cost of your meal including a tip will come to: $", round((principal+Exceltip),2)
  elif service == Average or average:
    print("Tip = ",avgtip)
    print("The cost of your meal including a tip will come to: $", round((principal+avgtip),2)
  elif service == Poor or poor :
      print("Tip = ", poortip)
      print("The cost of your meal including a tip will come to: $",round((principal+poortip)2)
  else print("The input is invalid."")
main()
cs95
  • 379,657
  • 97
  • 704
  • 746
  • what is your definition of "Excellent" etc.? – Banana Jan 28 '18 at 03:14
  • `if service == Excellent or excellent` that's not what you want to do, you probably mean: `if service == Excellent or service == excellent`. Same goes to the other conditions. – Nir Alfasi Jan 28 '18 at 03:14
  • The _syntax_ problem is just mismatched parentheses (and at least one missing comma). But do see the question of which this is marked a duplicate; you’ll need it too. – Davis Herring Jan 28 '18 at 03:16
  • I've edited your title to the question you should be asking. – cs95 Jan 28 '18 at 03:16

0 Answers0