如何修复python项目中的顽固语法错误?

时间:2018-11-16 15:06:25

标签: python

我正在做一个学校项目,我几乎完成了。做一个子手游戏。在第32行的print(char)下面的“ else:”命令中,我一直遇到语法错误,到目前为止,我一直没有尝试解决此错误,并且编译器不会告诉我问题是除了语法错误之外

import time
Name =input("What is your name?")
print ("Hello,"+Name,"Time to play hangman")
print( "")
#wait for 1 second
time.sleep(1)
print("Start guessing...")
time.sleep(0.5)

#here we set the secret

word = "ball"

#creates an variable with an empty value

guesses = ""

#determine the number of turns
turns =10

#create a while loop

#check if the turns are more than zero
while turns > 0:         

#make a counter that starts with zero
  Failed =0
  #for every character in secret_word
  for char in word:
      if char in guesses:
        print (char,)
        else:
            print  (  "_", )    
            failed += 1    

          print ("You won")
          break
          print()
          guess = input ("guess a character:")
  guesses +=guess
  if guess not in word
  turns -=1
  print ("Wrong")
  print ("You have", turns, "more guesses")
  if turns ==0:
    print ("You Lose the Word was",word)

0 个答案:

没有答案