请参阅我的评论。他们解释我的问题。我有一个if语句,无论是什么和一个没有正确聚合的变量,我都不知道为什么。提前致谢。 (以下是目前正在开发的刽子手程序.printBody()最终将打印出整个人。)
import random
words = []
lettersGuessed = []
isGuessed = 0
wordFile = open(r'C:\Users\Sarah\PycharmProjects\hangman\words.txt')
for word in wordFile:
words.append(word.strip())
limbCount = 0
def printBody(limbCount):
limbCount += 1
if limbCount == 1:
print("\n0")
elif limbCount == 2:
print("\n0")
print("\n |")
return limbCount
mysteryWord = random.choice(words)
while len(mysteryWord) <= 1:
mysteryWord = random.choice(words)
for letter in mysteryWord:
print("?", end = "")
print("\n")
def isWon(mysteryWord, lettersGuessed):
#win conditions
count = 0
for letter in mysteryWord:
if letter in lettersGuessed:
count += 1
if count == len(mysteryWord):
isGuessed = 1
return isGuessed
count = 0
victory = 0
while not victory:
guess = input("Guess a letter \n")
if guess.upper() or guess.lower() in mysteryWord:
lettersGuessed.append(guess)
for letter in mysteryWord:
if letter in lettersGuessed:
print(letter, end ='')
else:
print("?", end = '')
#this statement is firing no matter what and I don't know why
if guess.upper() or guess.lower() not in mysteryWord:
#when I call printBody() limbCount increases to one but then stays there. It won't go up to two or three.
printBody(limbCount)
print("\n")
count = 0
victory = isWon(mysteryWord, lettersGuessed)
print("Congratulations, you correctly guessed ", mysteryWord)
答案 0 :(得分:1)
尝试:
ansible -m ping all -i <inventory_file> --private-key=~/.ssh/<your pem key.pem> -u <login user ubuntu/centos>
我相信你遇到了这个问题,因为它正在检查&#34;是guess.upper() not in mysteryWord or guess.lower() not in mysteryWord
truthy&#34;,因为它是一个字符串(这是真的),它将输入if语句