As pointed out in the comments, the problem is that random.sample
returns a list
, and that list
is never in deck
, but you are over-complicating this. Just do:
import random
NUMS_IN_DECK = 13
def take_card():
type_cards = "diamond", "heart", "spade", "club"
deck = [(i + 1 ,t) for i in range(NUMS_IN_DECK) for t in type_cards]
random.shuffle(deck)
for card in deck:
yield card
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…