Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么if语句的语法无效?_Python_If Statement - Fatal编程技术网

Python 为什么if语句的语法无效?

Python 为什么if语句的语法无效?,python,if-statement,Python,If Statement,如果我尝试运行代码,则会出现以下错误: 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

如果我尝试运行代码,则会出现以下错误:

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!"))

你为什么不试试呢

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

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

你为什么不试试呢

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

Tut_Ans2 = input(str(print("Guess you have to write Deny!"))
您有三个
,只有两个

您有三个
,只有两个