python中怎么在循环里删除字符串中的某个确定字符

img


题目如图

img


怎么修改这个代码让每次猜过的词不再出现?while循环条件要怎么写

这里有一个相同问题: 请查看是否对问题有帮助~
https://ask.csdn.net/questions/7705109

import random
right = 0
num = 1
W = ['play', 'guess', 'english']
repeat = 'yes'
while num < len(W)+ 1:
    word = random.choice(W)
    word1 =word
    answer  = 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 != answer:
        guess = input("重新猜测:")
    print("猜对了")
    W.remove(word1)
    right += 1

print("一共猜对了{}个词".format(right))
print("游戏结束")

望采纳!谢谢

问题重复提问啦

W.remove(guess)