How can I make it print ace instead of 1, jack instead of 11, queen instead of 12 and king instead of 13, while playing the game, with the python program still working properly.
Is there a way I can do this without changing too much.
This is my code:
import random
dealer_cards = []
player_cards = []
while len(dealer_cards) != 2:
dealer_cards.append(random.randint(1, 13))
if len(dealer_cards) == 2:
print('The dealer has a hidden card and', dealer_cards[1])
while len(player_cards) != 2:
player_cards.append(random.randint(1, 11))
if len(player_cards) == 2:
print('You have the cards,', player_cards)
if sum(dealer_cards) == 21:
print('The dealer has the cards,', dealer_cards)
print('The dealer has won because he has 21!')
exit()
if sum(player_cards) == 21 and sum(dealer_cards) == 21:
print('draw')
exit()
elif sum(dealer_cards) > 21:
print('The dealer has the cards,', dealer_cards)
print('The dealer has bust because he has over 21!')
exit()
while sum(player_cards) < 21:
choice = str(input('Choose twist or stick? '))
if choice == 'twist':
player_cards.append(random.randint(1, 11))
print('You now have the cards,', player_cards)
else:
print('The dealer has the cards,', dealer_cards)
print('You have the cards,', player_cards)
if sum(dealer_cards) > sum(player_cards):
print('The dealer has won!')
break
else:
print('You have won!')
break
if sum(player_cards) > 21:
print('You have bust because you are over 21!')
elif sum(player_cards) == 21:
print('You have won because you have 21')
Aucun commentaire:
Enregistrer un commentaire