Tell us what’s happening:

When I run my code separately, the error message shows up fine.

However, when I run multiple lines of code, error messages don’t show up properly. The messages from test 1 and 2 don’t show up as below.

Thank you very much.

Your code so far

```
def arithmetic_arranger(problems, ans = False):
line1 = ""
line2 = ''
line3 = ''
line4 = ''
soindex = 0
plist = map(lambda x: x.split(" "), problems)
for equations in list(plist):
if equations[0].isdigit() is False or equations[2].isdigit() is False:
return "Error: Numbers must only contain digits."
if equations[1] != "+" and equations[1] != "-":
return "Error: Operator must be '+' or '-'."
if len(equations[0]) > 4 or len(equations[2]) > 4:
return "Error: Numbers cannot be more than four digits."
```

This file has been truncated. show original

Your browser information:

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.51 Safari/537.36`

Challenge: Arithmetic Formatter

Link to the challenge:

ilenia
August 19, 2021, 3:04pm
#2
I think it is showing last executed value, as the first two functions do not execute a print statement, and the third one yes instead (though note that you should always return the value)

Thanks for the insight, I got a counter-intuitive solution. But I am pretty sure there is a way more efficient way of returning the error messages.

I would be thankful if you can offer me some suggestions on this matter.

You should not use `print`

. The instructions are to `return`

the error messages.

If you want to see what each function call does, then you can wrap your function calls in a `print`

.

Normally, you would `raise`

an error, which would stop execution of your code.

Thanks for all the replies. I have solved it. Much appreciated

1 Like

system
closed
February 18, 2022, 4:35am
#6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.