VACATION... TypeError: unsupported operand type(s) for -=: 'unicode' and 'int'


#1

please help me out…



city=raw_input("enter city")

days=input("number of days")

night=days-1

spending_cost=input("enter additional costs")

def hotel_cost(night):
  total=140*night
  
  return total


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
  
  else:
    return"INVALID INPUT"
  

  
def rental_car_cost(days):
  
  
 cost=days*40

 if days>=7:                  
   cost-=50
   return cost
 elif days>=3 and days<7:
    cost-=20
    return cost
 else:
   return cost
  
  
def trip_cost(days,city,spending_money):
  sum= rental_car_cost(days)+ hotel_cost(days-1)+plane_ride_cost(city)+spending_money
  return sum
  
  
  
print hotel_cost(night)  
print plane_ride_cost(city)   
print rental_car_cost(days)
print trip_cost(city,days,spending_cost)
  

the error

enter cityTampa
number of days12
enter additional costs12
1540
220
430
Traceback (most recent call last):
  File "python", line 57, in <module>
  File "python", line 49, in trip_cost
  File "python", line 39, in rental_car_cost
TypeError: unsupported operand type(s) for -=: 'unicode' and 'int'

#2

don’t use input(), it will read the input as code, use raw_input() to prompt for input and int() to convert to integer


#3

thanks got it …appreciate your help…


#4

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