Python 无法确定SyntaxError的原因:在第17行,<=100

Python 无法确定SyntaxError的原因:在第17行,<=100,python,Python,我在下面的代码中有语法错误,无法确定原因。此外,如果我注释掉elif语句,我的第12行实际上不会将变量添加到一起 #Define variables and collect inputs points = int(input("How many points do you have?: ")) years = int(input("How many years have you been a customer?: ")) points_disco

我在下面的代码中有语法错误,无法确定原因。此外,如果我注释掉
elif
语句,我的第12行实际上不会将变量添加到一起

#Define variables and collect inputs
points =  int(input("How many points do you have?:  "))
years =  int(input("How many years have you been a customer?:  "))

points_discount = float()

years_discount = float()

final_discount = float()

#formula for additional discount
final_discount = points_discount + years_discount

#if statements for the points
if points <= 50:
    points_discount == 0.00
elif points > 50 and <= 100:  # SyntaxError here.
    points_discount == 0.10
elif points >100 and <=200:
    points_discount == 0.20
elif points >200 and <=300
    points_discount ==  0.25
else:
    points_discount == 0.30

#if statement for the years as a customer
if years < 5:
    years_discount  == 0.00
else:
    years_discount == 0.05

print(str(final_discount), " is your discount") 
#定义变量并收集输入
points=int(输入(“您有多少个点:”)
years=int(输入(“您作为客户有多少年?:”)
积分\折扣=浮动()
年折扣=浮动()
最终折扣=浮动()
#附加折扣公式
最终折扣=积分折扣+年折扣
#关于要点的if语句
如果第50点和第100点以及第200点和两个主要问题:

  • 在每次
    if
    for
    while
    等之后,您必须使用冒号(
    )-在第21行中忘记

  • if
    语句应由返回
    True
    False
    的短语组成。您想知道变量是否在2个限制之间,您应该这样做-
    elif points>50和points这是正确的语法

    if points <= 50:
        points_discount = 0.00
    elif points > 50 and points<= 100:
        points_discount = 0.10
    elif points >100 and points <=200:
        points_discount = 0.20
    

    if points 50和points 100和points@JohnKugelman感谢您的解释。我发现我缺少if/elif语句右侧的points变量。我的另一个问题是第12行,最终打印报表始终打印0.00,即使编辑了
    final\u折扣=积分折扣+年折扣
    ,以解决您的额外问题。这是因为您使用了
    =
    而不是
    =
    来分配任务
    =
    用于比较元素Why
    points\u discount=float()
    而不是
    points\u discount=0
    ?单等分用于分配,双等分用于比较。
    if points <= 50:
        points_discount = 0.00
    elif points > 50 and points<= 100:
        points_discount = 0.10
    elif points >100 and points <=200:
        points_discount = 0.20