From b4ff7c58d023412c72dc3914ae3a5a4662a8af47 Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Tue, 8 Dec 2020 09:09:50 +0100 Subject: [PATCH] TIL: enumerate() exists; no more manual counting --- day08.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/day08.py b/day08.py index c1a1fca..aca46df 100644 --- a/day08.py +++ b/day08.py @@ -37,9 +37,7 @@ def part1(test_mode=False): def part2(test_mode=False): my_input = aoclib.getInputAsArray(day=DAY, test=test_mode) - counter = -1 - for check_command in my_input: - counter += 1 + for counter, check_command in enumerate(my_input): if not check_command.startswith('nop') and not check_command.startswith('jmp'): continue