2015-04-01 3 views
-1
#This will loop the try statement until an integer is entered as the guess1 variable 
    while True: 
     #The try statement will see if the guess variable is given an integer value, 
     #if not then it will print "You did not enter an integer. This is not a 
     #valid answer 
     try: 
      #This will allow the user to enter their answer and 
      #store it in the guess1 variable 
      guess1 = int(input("")) 
      #This will break the while loop if an integer is entered as the guess1 variable 
      break 
     except ValueError: 
      print("You did not enter an integer. This is not a valid answer. Please enter a valid integer") 
      print("Answer the quesiton appropiately" + "What is " + (str(first2) + op + str(second2) + "?") 
    if guess1 == answer1: 
     #If the guess1 variable is equal to the answer1 variable, then 
     #"Correct!" will be printed and one point would be 
     #added to the score 
     print("Correct!") 
     score += 1 
    else: 
     #Else "Incorrect" would be printed 
     print ("Incorrect") 

Оболочка утверждает, что есть недопустимый синтаксис с двоеточием, когда я набрал «guess1 == answer1:».Оболочка говорит «Недопустимый синтаксис»

+2

Подсчитайте круглые скобки на предыдущей строке. –

+0

Вот почему вы используете 'format' и не объединяете строки с' + '. – Matthias

ответ

2

Проблема в том, что вы не закрыли тег во второй строке в своем исключении. Добавьте дополнительный «)» до конца.

print("Answer the quesiton appropiately" + "What is " + (str(first2) + op + str(second2) + "?")) 
Смежные вопросы