()
| 18 | |
| 19 | |
| 20 | def start_game(): |
| 21 | random.shuffle(deck) |
| 22 | |
| 23 | d_cards = [] |
| 24 | p_cards = [] |
| 25 | |
| 26 | # Dealer initial cards |
| 27 | while len(d_cards) != 2: |
| 28 | random.shuffle(deck) |
| 29 | d_cards.append(deck.pop()) |
| 30 | if len(d_cards) == 2: |
| 31 | print("The cards dealer has are X ", d_cards[1]) |
| 32 | |
| 33 | # Player initial cards |
| 34 | while len(p_cards) != 2: |
| 35 | random.shuffle(deck) |
| 36 | p_cards.append(deck.pop()) |
| 37 | if len(p_cards) == 2: |
| 38 | print("The total of player is ", sum(p_cards)) |
| 39 | print("The cards Player has are ", p_cards) |
| 40 | |
| 41 | if sum(p_cards) > 21: |
| 42 | print("You are BUSTED !\n **************Dealer Wins !!******************\n") |
| 43 | return |
| 44 | |
| 45 | if sum(d_cards) > 21: |
| 46 | print( |
| 47 | "Dealer is BUSTED !\n ************** You are the Winner !!******************\n" |
| 48 | ) |
| 49 | return |
| 50 | |
| 51 | if sum(d_cards) == 21 and sum(p_cards) == 21: |
| 52 | print("*****************The match is tie !!*************************") |
| 53 | return |
| 54 | |
| 55 | if sum(d_cards) == 21: |
| 56 | print("***********************Dealer is the Winner !!******************") |
| 57 | return |
| 58 | |
| 59 | def dealer_choice(): |
| 60 | if sum(d_cards) < 17: |
| 61 | while sum(d_cards) < 17: |
| 62 | random.shuffle(deck) |
| 63 | d_cards.append(deck.pop()) |
| 64 | |
| 65 | print("Dealer has total " + str(sum(d_cards)) + " with the cards ", d_cards) |
| 66 | |
| 67 | if sum(p_cards) == sum(d_cards): |
| 68 | print("***************The match is tie !!****************") |
| 69 | return |
| 70 | |
| 71 | if sum(d_cards) > 21: |
| 72 | print("**********************Player is winner !!**********************") |
| 73 | return |
| 74 | |
| 75 | if sum(d_cards) > sum(p_cards): |
| 76 | print("***********************Dealer is the Winner !!******************") |
| 77 | else: |
no test coverage detected