I'm writing a fuel conversion program and its not working :(
Question: I am a novice python code writer and i am starting small with a fuel
conversion program. The program asks for your name and then converts a miles
per gallon rate or a kilometers per litre rate. Currently, the program runs
fine until it gets to the convert to MPG line. then once you press y, it does
nothing. funny thing is, no syntax error has been returned. please help as i
cannot find anything on it :(

    
    
    import time
    
    y = 'y', 'yes', 'yep', 'yea', 'ye'
    n = 'n', 'no', 'nup', 'nay'
    
    name = str(input("Hey, User, whats your name?   "))
    
    time.sleep(1.5)
    
    print("Alright", name, "Welcome the the *gravynet* Fuel Efficiency Converter!")
    
    time.sleep(1.5)
    
    str(input("Would you like to convert the fuel efficiency of your motor vehcile? (Miles Per Gallon) (y/n):    "))
    
    if y is True:
    
    miles = int(input("How far did you travel (in miles):   "))
    
    galls = int(input("How much fuel did you consume (in gallons):   "))
    
     mpgc = (galls/miles)
    
     print("The MPG Rate is:  ", int(mpgc))
    
     time.sleep(2)
    
     print("test print")
    if y is (not True):
    
      input(str("Would you like to convert KPL instead? (y/n):   "))
    
      time.sleep(1.5)
    
      if y is True:
    
       kilometers = int(input("How far did you travel (in kilometers):   "))
    
       litres = int(input("How much fuel did you consume (in litres):   "))
    
       kplc = ( litres / kilometers )
    
       print("The KPL Rate is:   ", int(kplc))
    
       time.sleep(3)
    
       exit()
    
    
      if y is not True:
    
       print("No worries")
    
       time.sleep(1.5)
    
       print("Thanks", name, "for using *gravynet* Fuel Efficiency Coverter")
    
       time.sleep(1.5)
    
       print("Have a good day!")
    
       time.sleep(1.5)
    
       exit()
    
      else :
         print("Sorry, invalid response. Try again")
         exit()
    
    
    elif not y:
    
      print("Please use y/n to answer" )
    
      time.sleep(2)
    
    elif not n:
    
      print("Please use y/n to answer" )
    
      time.sleep(2)
    

sorry if you think that is bad but i just started python and i need some help
:)


Answer: Severely trimmed down and indentation fixed (I think....)

`if y is True` and similarly `if y is not True` make no sense here.

Also, speaking of `is`.. `is` and `==` may be work as equivalent expressions
sometimes for checking for "equality", but not necessarily. `==` checks for
equality whereas `is` checks for object identity. You should use `==` for
checking for equality between two objects. Except for `None` in which case
it's generally preferred to use `is` instead of `==` for this.

You're converting to `str` in a bunch of places unnecessarily. They're already
strings.

In your mpg conversion you already have a floating point number (possibly an
int). There's no need to convert to an int here. Suppose mpg is < 1\. Then
`int` casting will make this return zero

Your math is also backwards. miles _per_ gallon. Similarly, kilometers _per_
gallon.

    
    
    name = input("Hey, User, whats your name?   ")
    print("Alright", name, "Welcome the the *gravynet* Fuel Efficiency Converter!")
    mpg = input("Would you like to convert the fuel efficiency of your motor vehcile? (Miles Per Gallon) (y/n): ")
    
    if mpg in y:
    
        miles = int(input("How far did you travel (in miles):   "))
        galls = int(input("How much fuel did you consume (in gallons):   "))
    
        mpgc = miles / galls
    
        print("The MPG Rate is:  ", mpgc)
    
    else:
        kpl = input("Would you like to convert KPL instead? (y/n):   ")
    
        if kpl in y:
            kilometers = int(input("How far did you travel (in kilometers):   "))
            litres = int(input("How much fuel did you consume (in litres):   "))
            kplc = kilometers / litres
            print("The KPL Rate is:   ", kplc)
    
        else:
    
            print("No worries")
            print("Thanks", name, "for using *gravynet* Fuel Efficiency Coverter")
            print("Have a good day!")
    

