|
30 | 30 |
|
31 | 31 | import random
|
32 | 32 |
|
33 |
| -Facecards = { |
| 33 | +face_cards = { |
34 | 34 | "K": 10,
|
35 | 35 | "Q": 10,
|
36 | 36 | "J": 10,
|
|
46 | 46 | "A": 1
|
47 | 47 | }
|
48 | 48 |
|
49 |
| -Question1 = input("What's your first card?: ") |
50 |
| -Question2 = input("What's your second card?: ") |
51 |
| -Question3 = input("What's your third card?: ") |
52 |
| -cardTotal = 0 |
| 49 | +question_1 = input("What's your first card?: ") |
| 50 | +question_2 = input("What's your second card?: ") |
| 51 | +question_3 = input("What's your third card?: ") |
| 52 | +card_total = 0 |
53 | 53 |
|
54 | 54 | while True:
|
55 |
| - if Question1 in Facecards: |
56 |
| - cardTotal += int(Facecards[Question1]) |
57 |
| - print(f"Question1: {Question1}") |
| 55 | + if question_1 in face_cards: |
| 56 | + card_total += int(face_cards[question_1]) |
| 57 | + print(f"question_1: {question_1}") |
58 | 58 |
|
59 |
| - if Question2 in Facecards: |
60 |
| - cardTotal += int(Facecards[Question2]) |
61 |
| - print(f"Question1: {Question2}") |
| 59 | + if question_2 in face_cards: |
| 60 | + card_total += int(face_cards[question_2]) |
| 61 | + print(f"question_2: {question_2}") |
62 | 62 |
|
63 |
| - if Question3 in Facecards: |
64 |
| - cardTotal += int(Facecards[Question3]) |
65 |
| - print(f"Question1: {Question3}") |
| 63 | + if question_3 in face_cards: |
| 64 | + card_total += int(face_cards[question_3]) |
| 65 | + print(f"question_3: {question_3}") |
66 | 66 | break
|
67 | 67 | else:
|
68 | 68 | print("Not valid")
|
|
73 | 73 | else:
|
74 | 74 | print("Not valid")
|
75 | 75 | break
|
76 |
| -if cardTotal < 17: |
77 |
| - print(f"Hit {cardTotal}") |
78 |
| -elif 17 <= cardTotal < 21: |
79 |
| - print(f"Stay {cardTotal}") |
80 |
| -elif cardTotal == 21: |
81 |
| - print(f"Backjack! {cardTotal}") |
82 |
| -elif cardTotal > 21: |
83 |
| - print(f"Already Busted {cardTotal}") |
| 76 | +if card_total < 17: |
| 77 | + print(f"Hit {card_total}") |
| 78 | +elif 17 <= card_total < 21: |
| 79 | + print(f"Stay {card_total}") |
| 80 | +elif card_total == 21: |
| 81 | + print(f"Backjack! {card_total}") |
| 82 | +elif card_total > 21: |
| 83 | + print(f"Already Busted {card_total}") |
84 | 84 | else:
|
85 | 85 | print("Not Valid")
|
86 | 86 |
|
87 | 87 |
|
88 | 88 |
|
89 |
| -# print(cardTotal) |
90 |
| - |
91 |
| -# total = int(Question1) + int(Question2) + int(Question3) |
92 |
| - |
93 |
| - |
94 |
| - |
95 |
| -# if total < 17: |
96 |
| -# print("Hit") |
97 |
| -# elif total <= 17 and total < 21: |
98 |
| -# print("Stay") |
99 |
| -# elif total == 21: |
100 |
| -# print("BlackJack!") |
101 |
| -# else: |
102 |
| -# print("Busted") |
103 |
| - |
104 | 89 |
|
105 | 90 |
|
106 | 91 | # Version 2 (optional)
|
|
0 commit comments