質問編集履歴
1
コード修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
下記コードで、「n」を選択しても While文を抜けることができない状態です。
|
2
2
|
エラーは、出ていないのですが、どこが間違っているのかわからない状態です。
|
3
|
+
昨日から、ずっと、修正していますが、どうにも解決することができません。(半ノイローゼ状態になってきています)
|
4
|
+
|
3
5
|
```
|
4
6
|
choice = input('HITしますか? (Y/N) : ').lower()
|
5
7
|
```
|
6
8
|
|
7
9
|
|
8
10
|
```python
|
9
|
-
|
11
|
+
while True:
|
10
|
-
while choice != quit:
|
11
12
|
choice = input('HITしますか? (Y/N) : ').lower()
|
12
13
|
if choice == 'y':
|
13
14
|
hit(player_hand)
|
14
15
|
print(f'引いたカードは{player_hand[-1]} 全てのカードは{player_hand} 合計は{total(player_hand)}')
|
15
16
|
if total(player_hand) > 21:
|
16
17
|
print('You lose...')
|
18
|
+
break
|
19
|
+
else:
|
17
|
-
|
20
|
+
# [n]を選択したときの処理
|
18
|
-
elif choice == 'n': # inputでnを選択してもprint文が表示されず、再度、inputの選択処理となってしまう。
|
19
|
-
print(f'dealerのカード{dealer_hand} - dealerの合計:{total(dealer_hand)}')
|
20
21
|
|
21
22
|
```
|