From a3f78144c69a11093124fc556fedd0caf98e495a Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 22 Apr 2024 17:44:30 +0100 Subject: use enumerate --- challenge-266/steven-wilson/python/ch-2.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/challenge-266/steven-wilson/python/ch-2.py b/challenge-266/steven-wilson/python/ch-2.py index f6603f73a4..fb88e6dc17 100644 --- a/challenge-266/steven-wilson/python/ch-2.py +++ b/challenge-266/steven-wilson/python/ch-2.py @@ -14,8 +14,7 @@ def is_x_matrix(matrix): True ''' matrix_size = len(matrix) - diagonal_position = 0 - for row in matrix: + for diagonal_position, row in enumerate(matrix): antidiagonal_position = matrix_size - diagonal_position - 1 x = [] if diagonal_position < antidiagonal_position: @@ -28,7 +27,6 @@ def is_x_matrix(matrix): x.append(row.pop(antidiagonal_position)) if not all(elem != 0 for elem in x) or not all(elem == 0 for elem in row): return False - diagonal_position += 1 return True -- cgit