-1

I have this code

import time
total = int(input("What has the total come to?"))
times = float(input("What percent tip are you going to leave? Example:       1.15     = 15%"))
time.sleep(1)
people = int(input("How many people are there?"))
time.sleep(1)
tip=total*times
share=tip/people
print("The total is:", round(tip, 3))
print("You all have to pay", round(share, 3), "Each")
time.sleep(1)
taxi = 0.45
home = str(input("Are you taking a Taxi home?"))
if home in ("Yes", "YES", "yes"):
    distance = int(input("How many miles do you have to go?")
    ammount=taxi*distance
    print("Your total for your Journey is", ammount)

I'm working on a taxi calculator and keep getting this error "Invalid syntax". The part that calculates the tip works.

fedepad
  • 4,509
  • 1
  • 13
  • 27
john bob
  • 3
  • 1
  • Please format your code. After you start your if, you definitly need to indent. – TobiasR. Jan 12 '17 at 15:33
  • Which version of Python are you using? Also, please format your code as a block by highlighting it all and using the code formatting button (`{}`), making sure the indentation reflects your actual script, and post the full error. – Ry- Jan 12 '17 at 15:33
  • Please format your code properly first to make it more readable. Thanks! – plamut Jan 12 '17 at 15:33
  • 1
    note enough parentheses here `int(input("How many miles do you have to go?")` – Jean-François Fabre Jan 12 '17 at 15:34
  • Is this your actual code? Check your indentation. – Nick is tired Jan 12 '17 at 15:35
  • Add a closing brace to `distance = int(input("How many miles do you have to go?")` i.e. `distance = int(input("How many miles do you have to go?"))`. Often if you forget something like this the error is flagged against the next line – doctorlove Jan 12 '17 at 15:52
  • Check [http://stackoverflow.com/questions/4960208/python-2-7-getting-user-input-and-manipulating-as-string-without-quotations](http://stackoverflow.com/questions/4960208/python-2-7-getting-user-input-and-manipulating-as-string-without-quotations), which advises on the use of `raw_input()` for Python 2.x series, as your program relies on the user being aware (how if not reading the source?) that he/she should input a string with double quotes otherwise one would get the error _NameError: name 'YES' is not defined_ – fedepad Jan 12 '17 at 15:53

1 Answers1

0

You are missing a parenthesis.It should be :

distance = int(input("How many miles do you have to go?"))

So it would end up looking like this:

import time

total = int(input("What has the total come to?"))
times = float(input("What percent tip are you going to leave? Example:       1.15     = 15%"))
time.sleep(1)
people = int(input("How many people are there?"))
time.sleep(1)
tip = total * times
share = tip / people
print("The total is:", round(tip, 3))
print("You all have to pay", round(share, 3), "Each")
time.sleep(1)
taxi = 0.45
home = str(input("Are you taking a Taxi home?"))
if home in ("Yes", "YES", "yes"):
  distance = int(input("How many miles do you have to go?"))
  ammount = taxi * distance
  print("Your total for your Journey is", ammount)
Taufiq Rahman
  • 5,600
  • 2
  • 36
  • 44