Plan your trip help


#1



except for ("Los Angeles", 5, 600) for everything else
It is printing " Oops, try again. It looks like the correct value (1955) was not printed."


https://www.codecademy.com/en/courses/python-beginner-P5YtY/1/6?curriculum_id=4f89dab3d788890003000096
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:
        pass
def rental_car_cost(days):
   rental_car_cost = 40 * days
   if days >= 7:
        return rental_car_cost - 50
   elif days >= 3 and days < 7:
        return rental_car_cost - 20
   else:
        return rental_car_cost
def trip_cost(city,days,spending_money):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money
    
print (trip_cost("Los Angeles", 2, 600))


#2

I just tested!
It works fine for me.
Try Change browser or deleting cache history or zooming(browser)!


#3

It looks like your indentations are off. If they aren't off, then go ahead and refresh the page. It should work for you.


#4

changed the browser, deleted cache history still the same result.


#5

corrected the indentations but still getting the same result.


#6

Okay. After running through this again, I believe I found the problem here. The instructions say this:

After your previous code, print out the trip_cost( to "Los Angeles" for 5 days with an extra 600 dollars of spending money.

Let me emphasize a number here. 5 days. Now, if we look at your final line of code, you have the following: print (trip_cost("Los Angeles", 2, 600)). The 2 = days. How many days did the instructions ask for?

Once you made the switch, go ahead and let me know if it worked.


#7

Ok now I understood what the problem was.
Since the instructor has asked only for ( "Los Angeles", 5, 600 ) and not for other simulations that I have been performing that's why it was giving me error.
Thanks


#8

print trip_cost("Los Angeles", 5, 600)
You only need one set of parentheses, including changing 2 to 5, as someone else already mentioned.


#9

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