所以我在列表中索引字母。如果我将“h”“e”“l”“l”“o”的字母放在列表中并尝试获取它们的索引,它会返回 0 1 2 2 4。如何获得第二个“l” " 显示为 3?
def gameboard():
print("_ " * len(secretword))
for i in secretword:
gameboardindexes.append("_ ")
def letterindexes():
for i in secretword:
wordindexes.append(i)
def guessLetter():
guess = input("Please enter one letter: ")
for i in wordindexes:
if guess == i:
x = wordindexes.index(i)
print(x)
secretword = input("Please enter word:")
wordindexes = []
gameboardindexes = []
wrongletters = []
letterindexes()
gameboard()
guessLetter()
呼唤远方
森林海
qq_花开花谢_0
相关分类