Scientific Computing with Python Projects - Arithmetic Formatter - 0YpzajO17pPMnZPbODD67

Tell us what’s happening:
Describe your issue in detail here.
The code wrote works pretty much perfectly and outputs correctly using the sample code as well as on my own console however the tests albeit 2 all fail.

Your code so far

https://replit.com/@EAWachira/freeCodeCamparithmetic-formatter?v=1

Your browser information:

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

Challenge: Scientific Computing with Python Projects - Arithmetic Formatter

Link to the challenge:

You are printing errors instead of returning them. Also, your spacing is not identical to the specification.

Oh okay easily fixable with the errors. But isnt the spacing 4 between problems?

-   3801      123
?            -
+   3801     123
- -    2    +  49
?            -
+ -    2    + 49
- ------    -----
?               -
+ ------    ----
-   11      3801      1      123         1
? -                    -
+  11      3801      1     123         1
- +  4    - 2999    + 2    +  49    - 9380
?   -                       -
+ + 4    - 2999    + 2    + 49    - 9380
- ----    ------    ---    -----    ------
?    -                         -
+ ---    ------    ---    ----    ------

The + is a line that was found, the - is a line that was expected

Thanks I think I have sourced where the issue is, but I honestly dont know why its giving that value. The code is meant to find the largest number using the max function between 123 and 49 but for some odd reason it picks 49 so it figures out the spacing using 49. But for all other instances it picks the right number

#Checks if operator is a '-'
            elif problem.find('-') != -1:
                sub = problem.split(' - ')
                #Checks if list of operands are integers only
                if "".join(sub).isnumeric() is False:
                    return 'Error: Numbers must only contain digits.'
                    continue
                #Initialize unique variables for format
                *lrg = max(sub)*

The line italicized

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Thank you so much, managed to by pass that using the map function and managed to get the code to pass all auto tests.

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