在python中对列表中的字符串和整数求和

2024-10-06 16:16:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图用Python2.7编写一个21点代码,但在给出一个输出后,我不知道如何对c1和c2求和。到目前为止,我的情况是:

def blackjackTips(c1,c2):
    print "Welcome to Blackjack!"
    print "Your cards are", name[c1-1],"&",name[c2-1]
    total= sum ([c1]+[c2])
    print "Your card total is",total
name = ('A','2','3','4','5','6','7','8','9','10','J','Q','K')
value = (11,2,3,4,5,6,7,8,9,10,10,10,10)

输出:

>>> blackjackTips(11,6)
Welcome to Blackjack!
Your cards are J & 6
Your card total is 17

*当前语法返回计算错误的和。总数应该是16。你知道吗

有人能提供指导吗?你知道吗

谢谢


Tags: tonameyouriscardaretotalcards