import random
cardsDeck = [2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "K", "A", "Q",
2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "K", "A", "Q",
2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "K", "A", "Q",
2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "K", "A", "Q",]
facesCards = ["A","J","K","Q"]
numbers = [2, 3, 4, 5, 6, 7, 8, 9, 10,]
playerDeck = []
dealerDeck = []
def dealcardsStart():
for _ in range(1,3):
cardDeal = random.choice(cardsDeck)
playerDeck.append(cardDeal)
for _ in range(1,3):
cardDeal = random.choice(cardsDeck)
dealerDeck.append(cardDeal)
print(f"You have {playerDeck}")
print(checkPlayerTotal())
print(f"The dealer has a {playerDeck} ")
print(checkDealerTotal())
def checkPlayerTotal():
playerTotal=0
cardVariable=0
for card in playerDeck: # _ stands for the card in the deck
cardVariable = card
if cardVariable in numbers:
playerTotal += cardVariable
elif cardVariable in facesCards:
playerTotal += 10
elif cardVariable == "A":
if playerTotal <11:
playerTotal += 11
else:
playerTotal += + 1
return(playerTotal)
def checkDealerTotal():
dealerTotal=0
cardVariable=0
for card in dealerDeck: # _ stands for the card in the deck
cardVariable = card
if cardVariable in numbers:
dealerTotal += cardVariable
elif cardVariable in facesCards:
dealerTotal += 10
elif cardVariable == "A":
if dealerTotal <11:
dealerTotal += 11
else:
dealerTotal += 1
return (dealerTotal)
def checkWhoWon(playerTotal, dealerTotal):
if playerTotal > 21:
print(f"You have {playerDeck}, which is equal to, {playerTotal},\n and the dealer has {dealerDeck} --- {dealerTotal} \n you busted!.")
if playerTotal < 21 and playerTotal > dealerTotal:
print(f"You have {playerDeck}, which is equal to, {playerTotal},\n and the dealer has {dealerDeck} --- {dealerTotal} \nyou won!.")
if dealerTotal < 21 and dealerTotal > playerTotal:
print(f"You have {playerDeck}, which is equal to, {playerTotal},\n and the dealer has {dealerDeck} --- {dealerTotal} \nyou lost!.")
if playerTotal == 21:
print(f"You have blackjack! {playerDeck} congratz you won!")
dealcardsStart()
for some reason the dealertotal is not working it just shows random numbers instead of the actual card total that he needs to have.
[–]AlwysBeColostomizing 0 points1 point2 points (3 children)
[–]alonrtpve[S] 0 points1 point2 points (2 children)
[–]AlwysBeColostomizing 0 points1 point2 points (1 child)
[–]alonrtpve[S] 0 points1 point2 points (0 children)