Я все еще очень начинающий с Python и сейчас использую codecademy.Я решил немного усложнить одну из тренировочных программ, и я столкнулся с этой ошибкой:
Traceback (most recent call last):
File "python", line 30, in <module>
File "python", line 24, in trip_cost
File "python", line 18, in rental_car_cost
TypeError: unsupported operand type(s) for -: 'unicode' and 'int'
Вот мой код:
def hotel_cost(nights):
# the hotel costs $140 per night
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):
cost = days * 40
if days >= 7:
cost -= 50
elif days >= 3 and days < 7:
cost -= 20
return cost
def trip_cost(city, days, spending_money):
return rental_car_cost(days) + hotel_cost(days - 1) + plane_ride_cost(city) + spending_money
x = raw_input("Where are you going? ")
y = raw_input("How many days are you going for? ")
z = raw_input("How much spending money are you taking? ")
print trip_cost(x, y, z)
Любая помощь будет высоко ценится, спасибо!Я новичок, поэтому мой язык Python немного ржавый.