Scientific Computing with Python Projects - Arithmetic Formatter

###I have the correct outputs when I test manually test but its failing tests. I need new set of eyes it must be something very silly

Your code so far

Your browser information:

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

Challenge Information:

Scientific Computing with Python Projects - Arithmetic Formatter

1 Like

As I can see problem might be in \n printed at the end of each input , but still dont know why is not working

All of your code should go into arithmetic_arranger.py and be called from main.py

main.py should be this:

# This entrypoint file to be used in development. Start by reading README.md
from pytest import main
from arithmetic_arranger import arithmetic_arranger

print(arithmetic_arranger(['3801 - 2', '123 + 49']))

# Run unit tests automatically
main(['-vv'])

And in your .replit change this line

run = “python arithmetic_arranger.py”

to this

run = “python main.py”

Then you will see some verbose errors indicating a problem with extra spaces

If you need guidance reading the errors:

An assertion error gives you a lot of information to track down a problem. For example:

AssertionError: 'Year' != 'Years'
- Year
+ Years
?     +

Your output comes first, and the output that the test expects is second.

AssertionError: ‘Year’ != ‘Years’

Your output: Year does not equal what’s expected: Years

- Year
+ Years
?     +

- Dash indicates the incorrect output
+ Plus shows what it should be
? The Question mark line indicates the place of the character that’s different between the two lines. Here a + is placed under the missing s .

Here’s another example:

E       AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]
E       assert '  3801      123    \n   - 2     + 49    \n------    -----    \n' == '  3801      123\n-    2    +  49\n------    -----'
E         -   3801      123
E         +   3801      123    
E         ?                ++++
E         - -    2    +  49
E         +    - 2     + 49    
E         - ------    -----
E         + ------    -----    
E         ?                +++++

The first line is long, and it helps to view it as 2 lines in fixed width characters, so you can compare it character by character:

'  3801      123    \n   - 2     + 49    \n------    -----    \n'
'  3801      123\n-    2    +  49\n------    -----'

Again, your output is first and the expected output is second. Here it’s easy to see extra spaces or \n characters.

E         -   3801      123
E         +   3801      123    
E         ?                ++++

Here the ? line indicates 4 extra spaces at the end of a line using four + symbols. Spaces are a little difficult to see this way, so it’s useful to use both formats together.

I hope this helps interpret your error!

1 Like

Thanks so much got it. But have Q with uploading. No matter which link i put there it says complete on freecode camp? Is that automatically checked or manually latter by someone. Now I typed run in command (sh: 1: run: not found) got this and cant run code anymore

Basically I cant press Done

Your .replit file is still incorrect

You need to change this line to:

run = “python main.py”

I think you might have missed my first message:
https://forum.freecodecamp.org/t/scientific-computing-with-python-projects-arithmetic-formatter/658735/4?u=pkdvalis

I saw. But I restarted whole replit process and opened new link arithmetic_arranger2. It passed all the test and I posted it on page and got completed tick.

But this I will remeber for the next task.

Thank you

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.