diff --git a/activity3-transfer.py b/activity3-transfer.py index 49d56a6..18bb3a1 100644 --- a/activity3-transfer.py +++ b/activity3-transfer.py @@ -3,7 +3,9 @@ import random -cards = [card for card in range(2, 11) for _ in range(4)] +# Generate cards +# The first list is for cards 2-10, the second is for cards J-A +cards = [card for card in range(2, 11) for _ in range(4)] + [10 for _ in range(0, 16)] def card_string(card: int) -> str: match card: @@ -24,8 +26,6 @@ random.shuffle(cards) def deal_card(cards: [int]) -> int: return cards.pop() -print(cards) - you = 0 dealer = 0 @@ -38,8 +38,6 @@ print("You got dealt", card_string(card1), "and", card_string(card2), "for a tot dealer += deal_card(cards) + deal_card(cards) -print("Shh dont tell them but the dealer has", dealer) - dealerWon = False while True: @@ -62,3 +60,18 @@ while True: if not dealerWon: print("Dealing the dealer") + print("Dealer has", dealer) + while dealer < 16: + card = deal_card(cards) + dealer += card + print("Dealer got", card_string(card), "they have", dealer) + if dealer > 21: + print("Dealer is bust!") + dealerWon = False + break + +if dealerWon: + if you > dealer: + print("You win!") + else: + print("Dealer wins...") diff --git a/chookspace/index.html b/chookspace/index.html index ff6cc1d..745cee8 100644 --- a/chookspace/index.html +++ b/chookspace/index.html @@ -4,7 +4,7 @@