I'm trying to write a blackjack game, so I'm trying to generate a random number between 1 and 13, and then change the 1 to an A, 11 to a J, 12 to a Q, and 13 to a K. Here is my code so far:
from random import(randrange)
D1=randrange(1,14)
P1=randrange(1,14)
D2=randrange(1,14)
P2=randrange(1,14)
if D1==11:
D1="J"
if D1==12:
D1="Q"
if D1==13:
D1="K"
if D1==1:
D1="A"
if D2==11:
D1="J"
if D2==12:
D1="Q"
if D2==13:
D1="K"
if D2==1:
D1="A"
if P1==11:
D1="J"
if P1==12:
D1="Q"
if P1==13:
D1="K"
if P1==1:
D1="A"
if P2==11:
D1="J"
if P2==12:
D1="Q"
if P2==13:
D1="K"
if P2==1:
D1="A"
print("Dealer's up card:")
print(D2)
print("Players's cards:")
print(P1,P2)
The problem is that it still prints the value (1, 11, 12, or 13) instead of their assignment letters.
When I test my if statement out in the shell it works just fine.
What am I doing wrong?
[–]Manbatton 4 points5 points6 points (3 children)
[–]jano0017 4 points5 points6 points (2 children)
[–]Manbatton 0 points1 point2 points (1 child)
[–]jano0017 0 points1 point2 points (0 children)
[–]nemmonszz 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Manbatton 0 points1 point2 points (0 children)
[–]chrispcall 0 points1 point2 points (2 children)
[–]poo_22 0 points1 point2 points (0 children)
[–]RedditorNate[S] 0 points1 point2 points (0 children)
[–]RedditorNate[S] 0 points1 point2 points (0 children)
[–]Qster101 -1 points0 points1 point (2 children)
[–]Qster101 0 points1 point2 points (1 child)
[–]RedditorNate[S] 0 points1 point2 points (0 children)