Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions code/jonpan/lab04.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cards = {
"A": 1,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
"6": 6,
"7": 7,
"8": 8,
"9": 9,
"10": 10,
"J": 10,
"Q": 10,
"K": 10,
}

selection_1 = input("\nSelect the first of three cards: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K. ")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • An idea for future work is to provide a way for user to input either lower-case or upper-case card letters. Program could accept both 'a' and 'A'.

selection_2 = input("\nSelect the second card: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K. ")
selection_3 = input("\nSelect the third and last card: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K. ")

selection_1_int = cards[selection_1]
selection_2_int = cards[selection_2]
selection_3_int = cards[selection_3]
sum = selection_1_int + selection_2_int + selection_3_int

if sum < 17:
print(f"\n{sum} Hit")

elif sum in range (17, 20):
print(f"\n{sum} Stay")

elif sum == 21:
print(f"\n{sum} Blackjack")

elif sum > 21:
print(f"\n{sum} Already Busted")