Stuck on the "Arithmetic Formatter" project

Greetings! Im fairly new in Python so I apologize in advanced if my code makes you crave spaghetti.

The code runs perfectly on my pc’s CMD but when I run it in replit the page tells me the characters distribution is wrong in every answer. Unfortunately I cant quite understand the feedback given by the page so I would appreciate if any of you could explain to me where Im failing.

Here is my code to the “Arithmetic Formatter” project in replit:
[https://replit.com/@J0RG3M3ND0Z4/boilerplate-arithmetic-formatter-3#main.py]

Thank you so much for your help.

There is no code, please check again ^^°

Edited, thank you for pointing that out.

Ok the errors are actually quite simple, though a bit hard to read because of formatting.
Basically, the first couple errors are because you are including the results of the calculations. Those should only be included if the optional second argument is True.
With this comes later errors when the argument is given → because your function doesn’t accept it.

Finally, one of your error messages starts with “Error: Error:”.

Wow, talk about being unable to see the forest for the trees, thank you very much. Must confess that part about the second argument being a boolean expression got me completely lost .

Your advice helped me correct these errors but unfortunately I’m still getting new ones: I noticed they only occured when problems is a list within a list, so I tried to cheat around it in line 7 but the error persist so I assume its elsewhere. :sweat_smile:

For example, when problem = [[‘3 + 855’, ‘3801 - 2’, ‘45 + 43’, ‘123 + 49’]]:

E assert ’ 3 3… 88 172’ == ’ 3 3…---- -----’
E Skipping 87 identical leading characters in diff, use -v to show

if I understand correctly the program is expecting dashes instead of the answer for the third problem (88)?
Its quite confusing.

Yeah in this scenario, the assertion-error message is not very helpful.
Though looking at your code, you are setting secpar to True in line 35 right before checking it’s value. So I assume the error is, that you are still returning the result.

I must admit I dont quite follow the logic behind the boolean second argument. Does the replit program turns the second argument to True or the code must have a line doing so? If the latter is correct why wouldnt it work in line 35, after discarding all possible error sceneries but before assigning arranged_problems value? I even set turning sec to True at line 19 right after the last Error: message inside the for loop and checked for it at line 36 (outside the loop) but it keeps returning the same error.

Again thank you so much for your time and guidance, I really appreciate it.

You can see in the test_module.py (or so) how the function will be calles.
Sometimes with one argument, sometimes with two. The first is the array with the problems, the second is to determine if you should include the result of the calculation. You just set the default value, but if the argument is actually provided in the call, it will take that one instead.

I found the answer!.. by checking another guy’s code here in the forum. It was such an idiotic error (The problem clearly said if the second parameter is not set to True, the ANSWERS should not be displayed but I was writting it as if the RESULT shouldnt). Cant believe the source of all these troubles boiled down to me being unable to read a fricking sentence…
Thank you so much for your help anyway, I feel like crap for having to look at code written by somebody else to found the source of the problem (even if it was by accident) but thats on me, you were nothing but supportive. :man_bowing:

Ah don’t bother. I’ve done that a couple of times when I got really stuck :wink:
On top of that, you understood the code right away AND figured out your error AND it was no big deal - you missunderstood a sentence, you didn’t have huge logic errors. So that’s all good signs because as a programmer, you’ll have to read other peoples code a lot.

So don’t sweat it. Later on as a programmer you’ll often search and copy other peoples code. So being able to quickly grasp it is a skill equally important.

Thanks man, I appreciate your comment.