编写python背单词程序

有一个程序请教一下各位
计算机从下面的单词表["python","game","food","easy","number","integer"]中随机抽取一个单词(例如:game),随机打乱字母顺序后(例如打乱成emga)展示给玩家,让玩家去猜是哪个单词。玩家猜错,给出提示“不对,请重猜”;玩家猜对,给出提示“恭喜,猜对了!
继续吗?(Y/N)",玩家输入“Y”或“y”继续,输入“N”或“n”退出。

给个例子,仅供参考:

import random
 
WORDS = ["python","game","food","easy","number","integer"]
while True:
    if len(WORDS)==0:
        print('恭喜,全猜完了')
        break
    word = random.choice(WORDS)
    cur_word = word
    a = ''
    for i in word:
        postion = random.randrange(len(word))
        a += word[postion]
        word = word[0:postion] + word[(postion+1):]
    print("乱序后的单词:", a)
    guess = input("输入你的猜测:")
    while guess!=cur_word:
        guess = input("不对,请重猜:")
    s = input('恭喜,猜对了!继续吗?(Y/N)')
    if s=='Y' or s=='y':
        WORDS.remove(cur_word)
        continue
    else:
        break

img

你好,如有帮助,请采纳!


import random

WORDS = ("python","game","food","easy","number","integer")

word = random.choice(WORDS)

correct = word

jumble = ""

while word:

position = random.randrange(len(word))

jumble += word[position]

word = word[:position] + word[(position + 1):]

print(

"""

Welcome to WORD JUMBLE!!!

Unscramble the leters to make a word.

(press the enter key at prompt to quit)

"""

)

print("The jumble is:", jumble)

guess = input("Your guess: ")

while guess != correct and guess != "":

print("不对,请重猜")

guess = input("Your guess: ")

if guess == correct:

print("恭喜,猜对了!继续吗?(Y/N)!\n")