From 13353165cbfe05308fa7edfdc3eb73045af74c0d Mon Sep 17 00:00:00 2001 From: Dominoc14 Date: Sun, 5 Mar 2023 07:40:01 -0500 Subject: [PATCH] Move the global declaration of k to line 44 to solve the following error "name 'k' is assigned to before global declaration" --- Python/DeleteEmptyComponents.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/DeleteEmptyComponents.py b/Python/DeleteEmptyComponents.py index 0830d8a..6b15fc4 100644 --- a/Python/DeleteEmptyComponents.py +++ b/Python/DeleteEmptyComponents.py @@ -42,6 +42,7 @@ def main(): # Delete all immediate occurrences of the empty components. deletedComponents = [] + global k k = 0 for component in componentsToDelete: @@ -52,7 +53,7 @@ def main(): occurrences = root.allOccurrencesByComponent(component) uniqueOccurrences = [] for occurrence in occurrences: - global k + for k in range(0, len(uniqueOccurrences)): if occurrence is uniqueOccurrences[k]: break