From 5419f827a2764e165cec92fe621dd17f81e96be5 Mon Sep 17 00:00:00 2001 From: Phoenix-2256 <122556371+Phoenix-2256@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:30:09 +0530 Subject: [PATCH] Update arithmetic_arranger.py The original code does not recognize a situation where the problems contain only '+' or only '-' as the operator. Although this condition is completely fair, the code gives an error message. Now, it will recognize length = 1 with either + or - as a legitimate scenario and will continue the function rather than returning error. --- arithmetic_arranger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arithmetic_arranger.py b/arithmetic_arranger.py index 6f59604..a6abfba 100644 --- a/arithmetic_arranger.py +++ b/arithmetic_arranger.py @@ -6,7 +6,7 @@ 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: + if set(operations) not in [{'+'}, {'-'}, {'+', '-'}] and len(set(operations)) > 2: arranged_problems = "Error: Operator must be '+' or '-'." return arranged_problems