Transportation


#1



https://www.codecademy.com/courses/python-beginner-P5YtY/1/3?curriculum_id=4f89dab3d788890003000096


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: unindent does not match any outer indentation level (python, line 14)

I don't understand what I am doing wrong here, I'm almost positive I followed the directions correctly.


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


#2

In def rental_car_cost()
try to write
Elif days <=3:
Hope it mighy help


#3

I did what you said and put "elif days <=3:" within def rental_car_cost() and it didn't fix the original problem.


#4

Keep your original code that you posted at the beginning. You are really close!

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

I didn't make any changes above, but I would recommend to make sure that indentation is correct; it looks like cost = days * 40 is off. Not sure how you have it on your console, but it looks off here.

Okay, the instructions list for the if and elif functions as having a discount of 50. You wrote cost = as if you are wanting to find the new cost with the discount, but all that was written was just the cost = 50 or 20, respectively. If you were a customer looking into the cost with the discount, wouldn't that look strange to you? So if you were wanting to find the new cost, you would want to - the cost by the discount. Another method you could use -= the discount. You have two methods here. Test them out and let me know if it worked or not. Also, if this made sense!

Best of luck!

P.S. Look at your instructions again. Did it hint that an else: function was needed?


#5

Thank you, the "cost = days * 40" was incorrectly indented. I needed to backspace the indentation. Again thank you for your help.


#6

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