我正在学习python,但我似乎不明白为什么我的代码是错误的。
def rental_car_cost(days):
rent = 40 * days
if days >= 7:
rent -=50
elif days > 3 and days < 7: # is this allowed in Python?
rent -=30
return rent
我只想这样做3
我试图搜索if语句的语法,但无法在线找到答案。如果天数天数大于7,则租金=租金-50,如果天数大于3但小于7,则租金=租金-30。
def rental_car_cost(days): rent = 40 * days if days >= 7: rent -=50 elif days > 3 and days < 7: # is this allowed in Python? rent -=30 return rent
错误表明未定义功能rental_car_cost ...
我正在学习python,但我似乎不明白为什么我的代码是错误的。 def rental_car_cost(days):租金= 40 *天,如果天数> = 7:租金-= 50 Elif天数> 3,天数<7:#...
这是您所寻找的最接近的: