def showCards():
#SUM
sum = playerCards[0] + playerCards[1]
#Print cards
print "Player's Hand: " + str(playerCards) + " : " + "sum"
print "Dealer's Hand: " + str(compCards[0]) + " : " + "sum"
compCards = [Deal(),Deal()]
playerCards = [Deal(),Deal()]
How can i add up the integer element of a list containing to values? under #SUM error is can combine lists like ints…
Aside from the comments mentioned above, sum is actually a built in function in Python that does just what you seem to be looking for – so don’t overwrite it and use it as an identifier name! Instead use it.
Also there’s a style guide that all Python programmers are meant to follow – it’s what helps to further distinguish Python code from the inscrutable sludge often encountered in code written in other languages such as say Perl or PHP. There’s a higher standard in Python and you’re not meeting it. Style
So here’s a rewrite of your code along with some guesses to fill in the missing parts.
Well ok so I got carried away and actually wrote the whole thing. As another poster wrote sum(list_of_values) is the way to go but actually is too simplistic for the Black Jack rules.