条件中的语法错误

2024-05-14 04:21:22 发布

您现在位置:Python中文网/ 问答频道 /正文

65整数文本之前的=符号出现语法错误。有人能帮我弄清楚怎么纠正这个语法错误吗

age = int(input('Age? '))
if age <= 15 or >= 65:
  print('Discount Applied.')
else:
  print('Discount ineligible.')

Tags: or文本inputageif符号discount整数
2条回答

您需要在条件中再次指定age

age = int(input('Age? '))
if age <= 15 or age >= 65:
    # ...
age = int(input('Age? '))
if 15 < age < 65:
     print('Discount ineligible.')
else:
     print('Discount Applied.')

相关问题 更多 >