lundi 18 mars 2019

Why is it saying my else statement is invalid syntax in Python?

If I try to run my code, I get the error:

File "main.py", line 53 else: ^ SyntaxError: invalid syntax

My code is:

import time
import random
Lives = 5

print ("Hello, new recruit, welcome to the bank of Asgarde!")
time.sleep (1)
print (" ")
print ("A new law has been passed just yesterday.")
time.sleep (1)
print (" ")
print ("Now all cheques cashed in must be approved by the writer.")
time.sleep (1)
print (" ")
print ("You will need to write Approve is they match up.")
time.sleep (1)
print ("Or Deny if they don't match up.")
print (" ")
time.sleep (1)
print (" ")
print ("Oh look, our first customer! I'll show you how to do it.")
time.sleep (1)
print (" ")
print ("Okay, so here's the cheque that this person has just given to us.")
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 (1)
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 (1)
print (" ")
print ("Everything matches up, so now you need to type Approve to approve this cheque.")
Tut_Ans = input ()
if Tut_Ans == ("Approve"):
  print ("Good job!")
if Tut_Ans == ("Deny"):
  Lives = Lives - 1
  print ("No! Everything matched up!")
  print ("You now have " + str(Lives) + " lives left before you're fired!")
  else:
    print ("No! You have to type Approve or Deny!")

It refers to live 53 which says:

else:

I would be grateful for any help I can get on how to fix this. Thanks!

Aucun commentaire:

Enregistrer un commentaire