|
| 1 | +#Matt Nichols |
| 2 | +#Lab04 |
| 3 | + |
| 4 | +#Version 1 |
| 5 | + |
| 6 | +#Choices to pull from |
| 7 | +cards = { |
| 8 | + "a": 1, |
| 9 | + "2": 2, |
| 10 | + "3": 3, |
| 11 | + "4": 4, |
| 12 | + "5": 5, |
| 13 | + "6": 6, |
| 14 | + "7": 7, |
| 15 | + "8": 8, |
| 16 | + "9": 9, |
| 17 | + "10": 10, |
| 18 | + "j": 10, |
| 19 | + "q": 10, |
| 20 | + "k": 10 |
| 21 | +} |
| 22 | + |
| 23 | +#While loop so the user can continue to put numbers unless they feel like exiting |
| 24 | +while True: |
| 25 | + #Try and except block starting from the beginning to the end, so if they make an input error no matter where, it goes back to the top |
| 26 | + try: |
| 27 | + #Sequence of asking for the players hand starting with card one. ALSO, giving them a outing if they decide to exit |
| 28 | + card_one = input("What's your first card?\nYour options are (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K)\nType 'done' to exit\n").lower() |
| 29 | + if card_one == 'done': |
| 30 | + print("goodbye") |
| 31 | + break |
| 32 | + |
| 33 | + value_of_card_one = cards[card_one] |
| 34 | + print(value_of_card_one) |
| 35 | + |
| 36 | + #card 2 |
| 37 | + card_two = input("What's your second card?\nYour options are (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K)\nType 'done' to exit\n").lower() |
| 38 | + if card_two == 'done': |
| 39 | + print('goodbye') |
| 40 | + break |
| 41 | + |
| 42 | + value_of_card_two = cards[card_two] |
| 43 | + print(value_of_card_two) |
| 44 | + |
| 45 | + #card 3 |
| 46 | + card_three = input("What's your third card?\nYour options are (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K)\nType 'done' to exit\n").lower() |
| 47 | + if card_three == 'done': |
| 48 | + print('Goodbye') |
| 49 | + break |
| 50 | + |
| 51 | + value_of_card_three = cards[card_three] |
| 52 | + print(value_of_card_three) |
| 53 | + |
| 54 | + #Taking their cards and getting the total |
| 55 | + value_of_first_three_cards = value_of_card_one + value_of_card_two + value_of_card_three |
| 56 | + |
| 57 | + #If statement for what recommendation I should apply |
| 58 | + if value_of_first_three_cards < 17: |
| 59 | + print(f"Your total is: {value_of_first_three_cards}. I'd advise that you hit") |
| 60 | + elif value_of_first_three_cards >= 17 and value_of_first_three_cards < 21: |
| 61 | + print(f"Your total is: {value_of_first_three_cards}. I'd advise that you stay") |
| 62 | + elif value_of_first_three_cards == 21: |
| 63 | + print(f"Your total is: {value_of_first_three_cards}!!! Nice, that's blackjack") |
| 64 | + elif value_of_first_three_cards > 21: |
| 65 | + print(f"Your total is: {value_of_first_three_cards}... Sorry, you busted") |
| 66 | + |
| 67 | + except: |
| 68 | + print("That input did not go along with the choices that were presented\nEnsure that you put the options that are shown\n...............................................................") |
0 commit comments