Python 刽子手游戏中的循环与失误
上一次休息不起作用。这是因为它只呼吸FOR循环而不是while循环吗Python 刽子手游戏中的循环与失误,python,loops,while-loop,Python,Loops,While Loop,上一次休息不起作用。这是因为它只呼吸FOR循环而不是while循环吗 letter=input('Please enter the letter you guess: ') for alphabet in letter: if alphabet in words2: print('The letter is in the word.') i=i+1 if i==len(words2):
letter=input('Please enter the letter you guess: ')
for alphabet in letter:
if alphabet in words2:
print('The letter is in the word.')
i=i+1
if i==len(words2):
print('You have found the mystery word. You win!')
print('Goodbye!')
break
你好!!这是我正在写的一个刽子手游戏。我面临两个问题
多谢各位
我查了类似的问题,但没有一个有具体的解决方案,我也尽了最大努力编辑了这个问题。我不是100%确定,但我认为你的while测试是错误的
else:
continue
elif alphabet not in words2:
if letter not in alphabet:
print('You need to input a single alphabetic character!')
elif letter not in words2:
j=j+1
print('The letter is not in the word.')
whilejhi!你是否在你的2句话中编辑了我的while循环?看起来一样。还有其他原因吗?@vishal:而不是:)嗨,罗伯特。如果我加上“and”,那么这两个条件都必须是真的。我的工作条件是:I=单词长度或j=6个错误“不是”或“在这种情况下是更好的选择吗?答案只适用于6个字母的单词,不是吗?”?
else:
continue
elif alphabet not in words2:
if letter not in alphabet:
print('You need to input a single alphabetic character!')
elif letter not in words2:
j=j+1
print('The letter is not in the word.')
while j<6 or i!=len(words2):
while j<6 and i!=len(words2):