import random
WORDS = ("python","import","hello","difficult","easy")
print("欢迎来到猜单词游戏,请将乱序后的单词组成正确的单词")
iscontinue = "y"
while iscontinue == "y" or iscontinue == "Y" or iscontinue == "yes" or iscontinue == "YES":
words = random.choice(WORDS)
right = words
print(words)
newwords = ""
while words:
position = random.randrange(len(words))
newwords += words[position]
words = words[:position] + words[position + 1:]
print("乱序后的单词是:",newwords)
guess = input("请你猜单词:")
while guess != right and guess != "":
print("抱歉,你猜错了!")
guess = input("请你继续猜:")
if guess == right:
print("恭喜你猜对了!")
iscontinue = input("你是否继续游戏Y/N:")
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)