关于if语句的语法错误

时间:2015-04-15 01:20:02

标签: if-statement syntax

我是编程的新手,我正在尝试完成我的功能,但是在第一个if语句的第一个分号后,我在分号处不断出现语法错误。造成这种情况的原因是什么?如何解决这个问题并在将来避免这种错误?

def guess_who():
          y = random.randint(1,10)
          print("I'm thinking of an integer, you have three guesses")
          for i in range(3):
                a = eval(input('Please enter an interger between 1 and 10:')
                if a < y:
                         print("Your guess is too small.")
                elif a > y:
                         print("Your guess is too big.")

1 个答案:

答案 0 :(得分:0)

你错过了a)在带有eval函数的行的末尾。

def guess_who():
          y = random.randint(1,10)
          print("I'm thinking of an integer, you have three guesses")
          for i in range(3):
                a = eval(input('Please enter an interger between 1 and 10:'))
                if a < y:
                         print("Your guess is too small.")
                elif a > y:
                         print("Your guess is too big.")