Arithmetic Formatter fails only on main in replit

Hey, guys. I am relatively new to programming, so please bear with me.

I’ve recently finished the first challenge - I used IDLE to write the code before moving it to Replit. The script works fine except when I run main and the tests, which it fails entirely. Below pictures of the outcome on replit (while running my code alone).

Here goes the link. I also appreciate any other tips on the code structure.

Nice variety of errors ^^°

-   3801      123
+   3801      123    
?                ++++

Those are excess spaces at the end.

print('Error: Too many problems.')
>           sys.exit()
E           SystemExit

You are supposed to return error messages - not print and exit.

expected_output = 'Error: Numbers must only contain digits.'
fail_message = 'Expected calling "arithmetic_arranger()" with a problem that contains a letter character in the number to return "Error: Numbers must only contain digits."'

>   ???

Seems like you are not returning anything here.

>               second_digits.append(int(second[k]))
E               ValueError: invalid literal for int() with base 10: '3g5'

When the provided “thing” isn’t a number, you still try to cast it to an integer. So you are not catching this invalid input properly.

Thanks! Removing the trailing spaces and changing the error handling to return did the trick!

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