Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

summing string and integers in list in python

I am trying to write a blackjack code in python 2.7 and can't figure out how to sum my c1 and c2 once an output is given. This is what I have so far:

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)

output:

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

*The current syntax return the wrong sum is being calculated. The sum should be 16.

Could someone please provide guidance?

Thank you

like image 377
Tiffany Morris Avatar asked Sep 28 '22 14:09

Tiffany Morris


1 Answers

You need:

total = value[c1-1]+value[c2-1]
like image 108
R Sahu Avatar answered Oct 06 '22 00:10

R Sahu