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
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/184.108.40.206 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
Which part of the code is supposedly finding the largest 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.'
#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 (').
The lists you pass to
max function contain string and not numbers. String comparisons are compared by the ascii values of the characters.
“45” > “123” # True
Thank you so much, managed to by pass that using the map function and managed to get the code to pass all auto tests.