# Transportation

#1

guys can i please get some help here, i cant figure out.

``````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):
car_cost = days * 40

if days >= 7:
return car_cost -50
elif days <= 6 or days >= 3:
return car_cost -20
else:
return car_cost
``````

#2

The logic is a little off, here; since OR short-circuits on True, the first expression passes. Change the OR to an AND, or drop that operand altogether.

#3

so should i change this to something like

``````elif days>= 3 and days <= 6
``````

or something like

``````elif days>=3 and days<7

``````

#4

What is the discount structure? 7 or more days? 3 or more days? Or is it, more than 7 days? or more than 3 days?

The simplest logic is to rule out the maximum value firstâ€¦

``````if days > 7:
cost -= 50
elif days > 3:
cost -= 20
return cost
``````

or something along those lines.

#5

Got it, ill try the way you just told me .
I tried the crazy one i did. and worked . hahaha

but ill ttry yours too. Ill let you know

#6

you are right. too much thing .

We are supposed to use if and elif because it means between X and Y, in this case between 7 and 3.

thank you so much for your help.

#7

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