这段代码来自我的刽子手游戏,因为我不完全确定一个元组错误是什么以及如何解决它我来到这里。
Continue = input("Do you want to play hangman?").lower()
while Continue == ("y", "ye", "yes", "yeah").lower():
name = input("What is your name? ")
print ("Hello, " + name, "Time to play hangman! You have ten guesses to win!")
print ("\n")
time.sleep(1)
difficulty()
else:
quit
当我输入此代码时,我收到错误:
while Continue == ("y", "ye", "yes", "yeah").lower():
AttributeError:'tuple'对象没有属性'lower'
答案 0 :(得分:1)
AttributeError:'tuple'对象没有属性'lower'
意味着元组(如(1, 2, 3)
)不能lower
,因为小写只对str
有意义。
你可能意味着:
while Continue in ("y", "ye", "yes", "yeah"):