Im trying to figure out how to get the program to recognize what card was drawn and remove it from the deck so it cant be drawn again. I know I could have don't a list of 52 where I have each item be a card name and pull it from that list and put it in a new list but with the way I did this that doesn't seem possible. so how can I make it so it only draws a card one time?
import random
import time
played = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0]
def loop():
keepLooping = True
while(keepLooping):
global played
print ('The player with the lower card goes first')
print(' ')
# player One draw
draw = input("Player one would you like to draw?(y,n): ")
if draw == 'y':
CardNumber = random.randint(2,14)
Num2 = random.randint(2,4)
Royal = {11: "Jack",12: "Queen",13: "King",14: "Ace"}
cardnum1 = Royal.get(CardNumber, CardNumber)
suits = {1: "Spades", 2: "Hearts", 3: "Diamonds", 4: "Clubs"}
cardnum2 = suits[Num2]
DrawOne = [cardnum1, cardnum2]
print(DrawOne)
print(' ')
if draw == 'n':
print ('ok')
# player two draw
draw = input("Player Two would you like to draw?(y,n): ")
if draw == 'y':
CardNumber2 = random.randint(2,13)
Num3 = random.randint(2,4)
Royal = {11: "Jack",12: "Queen",13: "King",14: "Ace"}
cardnum3 = Royal.get(CardNumber2, CardNumber2)
suits = {1: "Spades", 2: "Hearts", 3: "Diamonds", 4: "Clubs"}
cardnum4 = suits[Num3]
DrawTwo = (cardnum3, cardnum4)
print(DrawTwo)
if draw == 'n':
print ('Then you lose')
# Win/lose/tie
if CardNumber == CardNumber2:
time.sleep(1)
print(' ')
print("it was a tie, lets re-draw")
print(' ')
keepLooping = True
else:
if CardNumber < CardNumber2:
keepLooping = False
time.sleep(.5)
print(' ')
print (DrawOne, 'Is the lower card, player 1 youre going first')
if CardNumber > CardNumber2:
keepLooping = False
time.sleep(.5)
print(' ')
print (DrawTwo, 'Is the lower card, player 2 youre going first')
loop()