Почему оператор if неверный синтаксис? - PullRequest
0 голосов
/ 21 марта 2019

Если я пытаюсь запустить свой код, я получаю сообщение об ошибке:

File "main.py", line 80
    if Tut_Ans2 == ('Approve'):
                              ^
SyntaxError: invalid syntax

Вот полный код:

import time
import random
Lives = 5

print ("Hello new recruit, welcome to the bank of \n")
time.sleep (0)

print ("A new law was just passed yesterday.\n")
time.sleep (0)

print ("Now all cheques must be approved by the writer.\n")
time.sleep (0)

print ("You will need to write Approve if they yeet.")
time.sleep (0)
print ("Or Deny if they don't yeet\n")

time.sleep (0)

print ("Oh look, our first customer, I'll show you how to do it.\n")
time.sleep (0)

print ("Okay, so here's the cheque that this person has just given to us.\n")
print (" ")
print (" ______________________________")
print ("|    29/09/06                  |")
print ("|  From: Cristian Western      |")
print ("|  To: Charlotte Webb   £1200  |")
print ("|    Age: 37     Gender: F     |")
print ("|      Bank of Sandle-land     |")
print ("|______________________________|")
time.sleep (0)
print (" ")
print ("And heres the approval cheque from the writer.")
print ("")
print (" ______________________________")
print ("|    29/09/06                  |")
print ("|  From: Cristian Western      |")
print ("|  To: Charlotte Webb   £1200  |")
print ("|    Age: 37     Gender: F     |")
print ("|      Bank of Sandle-land     |")
print ("|______________________________|")
time.sleep (0)
print (" ")
Tut_Ans = input(str("Everything matches up, so now you need to type Approve to approve this cheque.\n"))

if Tut_Ans == ('Approve'):
 print ("Good job!\n")
elif Tut_Ans == ('approve'):
 print ("Good Job!\n")
elif Tut_Ans == ('deny'):
 Lives = Lives - 1
 print ("No, these match up.\n")
elif Tut_Ans == ('Deny'):
  Lives = Lives - 1
  print (("You now have ") + str(Lives) + (" failures left until you're fired!\n"))
elif Tut_Ans != ('approve') or ('Approve') or ('Deny') or ('deny'):
  print ("No, you must type approve or deny.")

print ("Here comes another customer.\n")
print ("I'll show you again.\n")
print (" ______________________________")
print ("|    29/09/06                  |")
print ("|  From: Cristian Western      |")
print ("|  To: Charlotte Webb   £1200  |")
print ("|    Age: 37     Gender: F     |")
print ("|      Bank of Sandle-land     |")
print ("|______________________________|\n")
print ("And heres the approval cheque from the writer.\n")
print ("_______________________________")
print ("|    28/7/17                   |")
print ("|     From: Christian Western  |")
print ("|     To: Charlotte Web  £9000 |")
print ("|     Age: 92      Gender: M   |")
print ("|       Bank of Palm tree      |")
print ("|______________________________|/n")
print ("")
Tut_Ans2 = input(str(print("Guess you have to write Deny!"))

Ответы [ 2 ]

1 голос
/ 22 марта 2019

У вас есть три ( и только два ):

 Tut_Ans2 = input(str(print("Guess you have to write Deny!"))
1 голос
/ 21 марта 2019

Почему бы вам просто не попробовать

Tut_Ans2 = input("Guess you have to write Deny!")

вместо

Tut_Ans2 = input(str(print("Guess you have to write Deny!"))
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...