我需要帮助。除了3号,我完成了所有工作。如何将它们加在一起并平均值?
我不知道如何将值发送到hand_stats
我一直收到错误"NameError: name 'card' is not defined"
def deal_hand():
print ("Deal Hand")
print ("------------")
cards = []
cards.append(random.randint(1, 13))
cards.append(random.randint(1, 13))
cards.append(random.randint(1, 13))
cards.append(random.randint(1, 13))
cards.append(random.randint(1, 13))
display_hand(cards)
hand_stats(cards)
def display_hand(hand):
print ("The 5-card hand is: ")
for card in hand:
face_value(card)
它运行display_hand但它不运行hand_stats 谢谢你们
答案 0 :(得分:0)
使用
def hand_stats(card):
而不是
def hand_stats(hand):
答案 1 :(得分:0)
因为函数<img src="https://upload.wikimedia.org/wikipedia/commons/5/55/John_William_Waterhouse_A_Mermaid.jpg" alt="a mermaid">
<img src="" alt="an img tag in alt fallback mode">
<img id="css" src="" alt="an other img tag in alt fallback mode, but with some image set as content through CSS">
没有定义hand_stats
,所以它可能是原因,而card
是传递的函数变量名。因此,您可以尝试使用hand
:
sum(hand)