#猜单词游戏
import random
WORDS = ("python","juice","easy","difficult","answer","continue","phone","hello","pose","game")
print(
"""
欢迎参加猜单词游戏
把字母组合成一个正确的单词
""")
iscontinue = "y"
while iscontinue == "y" or iscontinue == "Y":
word = random.choice(WORDS)
correct = word
new = ""
while word:
pos = random.choice(range(len(word)))
new += word[pos]
word = word[:pos] + word[(pos + 1):]
print("乱序后的单词:",new)
guess = input("\n请你猜:")
while guess != correct and guess !="":
print("对不起,错了")
guess = input("请继续猜:")
if guess == correct:
print("恭喜你,猜对了!")
iscontinue = input("\n是否继续(Y/N):")
Python_猜单词游戏
最新推荐文章于 2023-11-19 21:20:15 发布