我几天前发布了一篇关于我正在努力建立的黑色杰克游戏......取得了一些进展!但是当我试图模拟交易的样子并修改套牌时,我无法打印修改后的套牌。
import random
suits = ['spades', 'hearts', 'clubs', 'diamonds']
ranks = ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'Jack', 'Queen', 'King']
def deck_func():
deck = []
for suit in suits:
for rank in ranks:
deck.append((rank, suit))
return deck
def deal(deck_func):
card_dealt = random.choice(deck_func())
return card_dealt
def dealt_deck(deck_func, deal):
card_deck = deck_func()
new_deck = card_deck.remove(deal(deck_func))
return new_deck
print deal(deck_func)
print dealt_deck(deck_func, deal)
我得到以下作为印刷功能...
('King', 'clubs')
None
我无法弄清楚原因。卡片列表正在创建......但新套牌不是出于某种原因。另一个奇怪的问题......如果我把'print deck_func()'放在其他打印函数之前,其他函数甚至不会触发......为什么会这样?
帮助!谢谢你!