From 71efcb2f901cf0180cf41ac388354e9f1dd9271e Mon Sep 17 00:00:00 2001 From: lone Date: Tue, 3 Sep 2024 13:09:26 +0800 Subject: [PATCH] fixed the bug if all operations are '+' or '-' --- arithmetic_arranger.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arithmetic_arranger.py b/arithmetic_arranger.py index 6f59604..c77bcaa 100644 --- a/arithmetic_arranger.py +++ b/arithmetic_arranger.py @@ -6,9 +6,10 @@ def arithmetic_arranger(problems, val=False): # list of all operations in str format operations = list(map(lambda x: x.split()[1], problems)) - if set(operations) != {'+', '-'} and len(set(operations)) != 2: - arranged_problems = "Error: Operator must be '+' or '-'." - return arranged_problems + for opt in operations: + if opt not in {'+', '-'}: + arranged_problems = "Error: Operator must be '+' or '-'." + return arranged_problems numbers = [] # list of all operands in str format for i in problems: