[Tutor] Codeacademy Problem

Joseph Parkton jparkton at gmail.com
Mon Apr 29 17:28:54 CEST 2013


I tried both suggestions from Chris and I get Oops, try again! Did you
create a function called trip_cost? Not really sure why



On Mon, Apr 29, 2013 at 9:24 AM, Sacha Rook <sacharook at gmail.com> wrote:

> Hi
> Do you need to;
>
> return totalCost in the function trip_cost
>
> so when you call trip_cost(city, days) it gives you something back?
>
> Hope it helps
>
> S
>
>
> On 29 April 2013 16:15, Joseph Parkton <jparkton at gmail.com> wrote:
>
>> 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.
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130429/077346cb/attachment.html>


More information about the Tutor mailing list