如何根据另一个数组的条件(对于扑克牌)从数组中排除一个项目?

How to exclude one item from an array based on another array's condition (for deck of playing cards)?

我有两个数组,一个用于纸牌花色 suit_list = ["Hearts", "Diamonds", "Clubs", "Spades"],另一个用于值 value_list = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]

我随机给select一张卡片写了代码。

基于此,对于随机卡 selected 例如2 颗钻石,我想防止再次被select编辑。

我该如何应对这种方法?我最初的想法是在嵌套 for 循环中使用条件方法,但它似乎不起作用。

感谢您的帮助。

与其考虑从游戏中移除一张牌,不如创建一副牌,将其洗牌,然后当您需要牌组中的牌时,只需从阵列中取出下一张牌即可。

import random
import itertools

suit_list = ["Hearts", "Diamonds", "Clubs", "Spades"]
value_list = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]

deck = list(itertools.product(suit_list, value_list))
random.shuffle(deck)

for card in deck:
    print(card)