Skip to content

Commit a941603

Browse files
committed
cleanup and refactor
1 parent 4313bdf commit a941603

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

21_tictactoe/tictactoe.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_args():
5353
if list(bord)[cell-1] != '.':
5454
parser.error(f'--cell "{cell}" already taken')
5555
else:
56-
if player and not cell:
56+
if any([player, cell]) and not all([player, cell]):
5757
parser.error("Must provide both --player and --cell")
5858

5959

@@ -180,11 +180,7 @@ def main():
180180
print(format_board(board))
181181

182182
winner = find_winner(board)
183-
print(f'{winner} has won!') if winner else print("No winner.")
184-
# print(f'board = "{board}"')
185-
# print(f'cell = "{cell}"')
186-
# print(f'player = "{player}"')
187-
183+
print(f'{winner} has won!' if winner else "No winner.")
188184

189185
def test_move():
190186
board = 'X.O'
@@ -193,7 +189,7 @@ def test_move():
193189

194190
def processMove(bord, cel, speler):
195191
updatedBord = list(bord)
196-
updatedBord [cel-1]=speler
192+
updatedBord[cel-1]=speler
197193
return ''.join(updatedBord)
198194
# --------------------------------------------------
199195
if __name__ == '__main__':

0 commit comments

Comments
 (0)