【问题标题】:Python: Syntax Error?Python:语法错误?
【发布时间】:2012-11-07 01:42:58
【问题描述】:
A=int(input('Enter the first of three numbers: '))
B=int(input('Enter the second of three numbers: '))
C=int(input('Enter the third of three numbers: '))
list=[A,B,C]
SL=sorted(list)
if SL[0]<0:
    if SL[1]-1==SL[0]:
        print (list('they are good'))
    else: print (list('not good'))
elif SL[2]-1==SL[1]:
    print (list('they are good')
else: print (list('not good'))

我一直在 else 和 : 之间的最后一行收到语法错误,当我在上面的第 3 行完全相同时,我不知道为什么它是错误的。非常感谢任何帮助。

【问题讨论】:

  • 你真的应该发布确切的错误信息。
  • 这只是括号,谢谢大家。

标签: python syntax if-statement


【解决方案1】:

你在倒数第二行缺少一个结束括号,它应该是:

    print (list('they are good'))

【讨论】:

    【解决方案2】:

    您在倒数第二行缺少一个尾随 ')'。

    【讨论】:

      【解决方案3】:
      elif SL[2]-1==SL[1]:
          print (list('they are good')
      

      在打印语句的末尾缺少结束 )

      【讨论】:

        猜你喜欢
        • 2011-10-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-16
        • 2017-12-03
        • 2012-09-27
        相关资源
        最近更新 更多