我已经提供了一个词的清单,将随机挑选游戏。它的作用是提示玩家输入所选单词的字母表。如果在所选单词中找到用户提供的字母,则会询问用户是否要尝试拼写整个单词。如果他们答应了,那么他们就能做到。否则,他们将不得不尝试进入另一个字母表。怎么我是否将每个用户输入的输出/结果打印为(例如:结果:a--------),如果用户最终对整个单词的拼写都说“是”,那么应该如何提示他们输入单词?
你想现在拼这个词吗?(是/否):是
拼写完整的单词:
你是对的!
正确的单词是albumen
拼另一个词?(是/否):是import random
wordList = ('apple', 'albumen', 'toothpaste', 'enthusiastic')
word = random.choice(wordList)
letter_guess = ""
word_guess = ""
store_letter = ""
count = 1
limit = 5
countLetters = len(word)
choice1 = ("Do you want to spell the word now? (y/n):")
choice2 = ("Spell another word? (y/n):")
choiceY = ("y")
choiceN = ("n")
startGame = print("The word ________ has {} letters. Spell it in 5 tries.".format(countLetters))
while count < limit:
letter_guess = input("Try {} - Current: ________. Your guess? ".format(count))
if letter_guess in word:
print ("yes")
print (input(choice1))
else :
print("no")
count += 1
if choice1 == choiceY:
print (input("Spell the complete word: "))
else:
print (letter_guess)
store_letter += letter_guess
count += 1
while count == limit:
spellFinal = input("Spell the complete word: ")
if spellFinal in word:
print ("You are correct!")
print ("Spell another word? (y/n):")
if choice == "y":
print (startGame)
else:
print('Remaining Words are: ', store_letter)
if spellFinal not in word:
print ("You are incorrect")
print ("The correct word is {}.".format(correct))