Transportation


#1

def hotel_cost(nights):
hotel_cost = 140 * 2
return hotel_cost

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

def rental_car_cost(days):
rental_car_cost = 40 * days

if days >= 7:
  cost = rental_car_cost - 50
  return cost
 elif :
     cost = return_car_rental - 20
    return cost

I was in confused state regarding my program can any one help me to solve this program.

when i hit save&submit
it showed me like this

File "python", line 21
elif :
^
IndentationError: unindent does not match any outer indentation level


#2

Hello! your problem is that in the elif part, the indentation must be on the same level as the if, like so;

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

#3

thank you for you help. i got program, you helped me in learning new thing.
thank you for spending your valuable time.


#4

no problem i love helping


#5

Will you be able to help me? this is my code:

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 = days * 40
if days >= 7:
cost -= 50

elif days >= 3:
cost - 20
return cost

I keep getting the error message "Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Your code threw the following error: 'return' outside function (python, line 24)"
ive been stuck for a while and cant do anything


#6

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
    else:
        return False
        
def rental_car_cost(days):
    cost = 40 * days
    if days >= 7:
        return cost - 50
    elif days >= 3:
        return cost -  20
    return cost

#7

thanks
helped me too :slight_smile:


#8

Thanks..

this helped me!


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.