混乱单词拼图的 Python 程序



我是python的新手,我只是在开发这个应用程序

import random
# create a sequence of words to choose from
WORDS = ("hello","goodbye","smile","evening","daytime")
#
# pick one word randomly from the sequence
word = random.choice(WORDS)
# create a variable to see if the guess is correct
correct = word
# create a jumbled version of the word
jumble =""
while word:
    position = random.randrange(len(word))
    jumble += word[position]
    word = word[:position] + word[(position + 1):]
# start the game
print( 
"""
        Welcome to the anagram quiz!
   Unscramble the letters to make a word.
(Press the enter key at the prompt to quit.)
""")
print ("The jumble is:", jumble)
guess = input("nYour guess: ")
guess = guess.lower()
while (guess != correct) and (guess != ""):
    print ("Sorry, that's not it.")
    guess = input("Your guess: ")
    guess = guess.lower()
if guess == correct:
    print ("That's it!  You guessed it!n")
print ("Thank you for playing.")
input("nnPress the enter key to exit.")
正如你所看到的,它混淆了一个单词,供用户

猜测这个词是什么,我需要能够改进这一点,以便用户在卡住时得到提示,并添加一个评分系统,奖励那些解决混乱而不要求提示的人。

我已经尝试了几个小时,但无处可去,你能帮我添加该功能吗?

谢谢。

对于提示部分:如果玩家猜错了指定的次数,他可以选择请求提示。提示将是您生成的内容以及可供选择的单词序列,成对形式。因此,当玩家卡住时,您将有一个单词和一个提示。

WORDS=[['hello','greeting'],['evening','sunset'],etc.]

至于分数部分:您可以进行基于时间的评分,他们每秒都会失去分数,直到他们猜对为止,或者基于猜测的评分,他们每次错误的猜测都会失去分数。

最新更新