Whats wrong with my code? 7/7


#1

heres my code

  def hotel_cost(nights):
    return 140 * nights

def plane_ride_cost(city):
    if(city == "Charlotte"):
        return 183
    elif(city == "Tampa"):
        return 220
    elif(city == "Pittsburgh"):
        return 222
    elif(city == "Los Angeles"):
        return 475

def rental_car_cost(days):
    cost = 40 * days
    if (days >= 7):
        return cost - 50
    elif(days >= 3):
        return cost - 20
    else:
        return cost

def trip_cost(city, days, spending_money):
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money
    
    import re

input_pattern = re.compile(r'[a-zA-Z]+(\s+\d{1,3}){2}\s+\d{1,6}')

print('Enter the city, number of days, nights and spending money')
print("eg 'Tampa 90 400 50'")
user_input = raw_input() # input() for python3.x users

while(not re.match(input_pattern,user_input)):
    print("Usage: string int int int")
    print("Enter the city, number of days, nights and spending money")
    user_input = raw_input() # input() for python3.x users

user_input = user_input.split()
print ("Hotel cost is $%s"%(hotel_cost(int(user_input[2]))))
print ("Total trip cost is $%s"%(trip_cost(user_input[0], int(user_input[1]), int(user_input[3]))))

#2

You shouldnt have indentation in front of import re

remove any kind of whitespace in front of def as well... :smile: