[Tutor] Codeacademy Problem

Joseph Parkton jparkton at gmail.com
Mon Apr 29 17:15:26 CEST 2013


I am working on a codeacademy problem and I am stuck. The instructions are
as follows:

INSTRUCTIONS

Below your existing code, write a function called trip_cost that takes two
inputs, city and days. cityshould be the city that you are going to visit
and days should be the number of days that you are staying.

Have your function return the *sum* of the rental_car_cost, hotel_cost, and
plane_ride_cost functions with their respective inputs.


my code so far looks like this:

def hotel_cost(nights):

    nights = nights * 140

    return nights



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):

    dailyCost = 40

    dailyCost = dailyCost * days

    if days >= 3:

        dailyCost = dailyCost - 20

    if days >= 7:

        dailyCost = dailyCost - 30

    return dailyCost



def trip_cost(city, days):

    totalCost = plane_trip_cost(city) + hotel_cost(nights) +
rental_car_cost(days)

    #And here is where I am stuck...


It is probably a simple answer but I don't know how to accomplish it. Any
help is appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130429/04389843/attachment.html>


More information about the Tutor mailing list