Skip to content

Commit 0ea63e3

Browse files
committed
print board before showing winner
1 parent 33582a3 commit 0ea63e3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

22_itictactoe/solution1.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ def main() -> None:
2525

2626
if state.error:
2727
print(state.error)
28+
elif state.winner:
29+
print(f'{state.winner} has won!')
30+
break
2831

2932
state = get_move(state)
3033

3134
if state.quit:
3235
print('You lose, loser!')
3336
break
34-
elif state.winner:
35-
print(format_board(state.board))
36-
print(f'{state.winner} has won!')
37-
break
3837
elif state.draw:
3938
print("All right, we'll call it a draw.")
4039
break

22_itictactoe/solution2_typed_dict.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ def main() -> None:
3030

3131
if state['error']:
3232
print(state['error'])
33+
elif state['winner']:
34+
print(f"{state['winner']} has won!")
35+
break
3336

3437
state = get_move(state)
3538

3639
if state['quit']:
3740
print('You lose, loser!')
3841
break
39-
elif state['winner']:
40-
print(format_board(state['board']))
41-
print(f"{state['winner']} has won!")
42-
break
4342
elif state['draw']:
4443
print('No winner.')
4544
break

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy