我正在尝试在python 2.7中编写一个二十一点代码,并且在给出输出后无法弄清楚如何对我的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.
有人可以提供指导吗?
谢谢
答案 0 :(得分:4)
你需要:
total = value[c1-1]+value[c2-1]