I am working on importing random
in Python 2.7. I would like for this code to generate two random cards. The current code does not generate random cards. If I request cards (9,11) the code generates cards (9,J) totaling to 19. There is nothing random about the output.
def blackjack(A,B):
print "Welcome to Blackjack!"
print "Your cards are",name[A-1],"&",name[B-1]
total = value[A-1] + value[B-1]
print "Your card total is",total
import random
A = random.randint(1,13)
B = random.randint(1,13)
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)
example output:
>>> blackjack(9,11)
Welcome to Blackjack!
Your cards are 9 & J
Your card total is 19
Aucun commentaire:
Enregistrer un commentaire