Pull It Together ---> Problemito


Hi there' I think I did exactly what i needed to but I got this massage:
Oops, try again. trip_cost('Charlotte', 5) raised an error: unsupported operand type(s) for -=: 'str' and 'int'
and if I press submit again it's variable to:
trip_cost('Los Angeles', 9) raised an error: unsupported operand type(s) for -=: 'str' and 'int'

this is my program:
def hotel_cost(nights):
return nights*140

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 7>days>=3:
total -= 20
return total

def trip_cost(days, city):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)



Please re-edit your Post

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.

or even better use
= http://discuss.codecademy.com/t/using-backticks-to-format-your-code/3697


if condition:
elif condition:

days >= 7
days >= 3


This worked for me:

def trip_cost(city, days):   
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)


That error message says that it doesn't know how to subtract an integer from a string.

Is that what you wanted to do? That operation doesn't really make sense does it, so probably not.

Use print statements to figure out which value is not what you want it to be, and keep adding print statements to track down where it is coming from.

You know it's at a -= operator of which you only have two, if you reproduce the error yourself by adding a test which triggers the error then you'll get the full error which will include the line number so you know exactly where to put that first print.