Trip_cost should have only 3 parameters error


#1

Codecademy logo
Learn Python

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

def rental_car_cost(days):

total = days * 40

if(days >= 7):

 total -=50

elif(days >= 3):

 total -=20

 return total

def trip_cost(city,days,spending_money):

 return plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days) + spending_money

 print trip_cost("Los Angeles",5,600)

#2

if statements do not need parens around the conditional expression. Try removing them in all your code.

if city == "Charlotte":

It may not be a problem for Python (can’t say with any certainty) but the lesson checker may be looking for specific code patterns.


#3

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
def rental_car_cost(days):
total = days * 40
if days >= 7:
total -=50
elif days >= 3:
total -=20
return total
def trip_cost(city,days,spending_money):
return plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days) + spending_money
print trip_cost(“Los Angeles”,5,600)


#4

Now it says It looks like nothing was printed to the console!


#5

Unable to fix this and due to this error it does not allow me go further :frowning_face:


#6

based on your original post, it appears your print trip_cost line is indented inside the trip_cost function. If thats the case trip_cost will never get called and you need to move it outside of the function


#7

3 posts were split to a new topic: Do not understand what is wrong with the code


#8

Just had the same problem and that was the fix! Thanks!


#9

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