简体   繁体   English

Elif Sytax错误Python

[英]Elif Sytax Error Python

I'm new to coding and got an error I don't know how to fix it. 我是编码新手,但出现错误,我不知道如何解决。 It is from codecademy lesson 4. 它来自codecademy课程4。

 def hotel_cost(nights):
  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
      cost -= 20


File "python", line 17
        elif days >= 3
           ^
    SyntaxError: invalid syntax

if someone knows what is wrong could you please help. 如果有人知道出什么问题了,请您帮忙。

You forgot a : 您忘记了:

Change elif days >= 3 to elif days >= 3: elif days >= 3更改为elif days >= 3:

And unindent the line 并缩进线

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

Might want to read this: https://docs.python.org/3/tutorial/controlflow.html 可能想阅读以下内容: https : //docs.python.org/3/tutorial/controlflow.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM