我想从列表中删除随机出现的 'A' 'B' 'C' 字符串

I want to remove randomly appearing 'A' 'B' 'C' strings from a list

我有以下列表结果。这是文章AB测试得到的结果

texts = [
    'A text',
    '89',
    '71%',
    '10%',

    'B',
    'B text',
    '110',
    '50%',
    '9%',

    'C',
    'C text',
    '30%',
    '4%'
    ]

texts2 = [
    'A'
    'A text',
    '89',
    '71%',
    '10%',

    'B',
    'B text',
    '110',
    '50%',
    '9%',

    'C text',
    '30%',
    '4%'
    ]

只有此列表中的最佳结果不包含任何字母 'A'、'B' 或 'C'。在此列表中,A 结果不包含 'A'。 但是我想知道如何处理没有 'B' 和 'C' 作为字符串出现的列表的可能性。

我现在正在尝试以下代码,但它不起作用。

有什么好的解决办法吗?

while ('A' or 'B' or 'C') in texts:
    try:
        texts.remove('A')
        texts.remove('B')
        texts.remove('C')
    except Exception as ex:
        print(ex)

试试这个:

texts = [
    'A text',
    '89',
    '71%',
    '10%',

    'B',
    'B text',
    '110',
    '50%',
    '9%',

    'C',
    'C text',
    '30%',
    '4%'
    ]

exclude = ['A','B','C']
t = [x for x in texts if (x not in exclude)]
print(t)

输出:['A text', '89', '71%', '10%', 'B text', '110', '50%', '9%', 'C text', '30%', '4%']