Replit code not working for arithmetic arranger

Hey all,
I am new to all of this, from coding to using tools like replit. I have figured out the arithmetic arranger and it works flawlessly in my pycharm environment but I can’t get it to work or replit. Likely it has something to do with how replit is handling the automated input of the problems into my code.

Any suggestions on how to get those inputs into a variable in my code?

Does running main.py file, or test file with pytest shows in pycharm that tests are passing?

This project isn’t expected to handle getting input from user on it own. It’s assumed that function will accept certain arguments, but where from these values are originating (keyboard, file, some randomness, etc.) is not a part of, or concern of the project.

I guess I should have been more clear, I’m not running the tests from the replit code to check if I am passing in pycharm, rather I’m just putting in the values I see there manually. I am unsure how to format my code to accept the inputs from test_module.py

The error I am getting is something to do with their container it seems
 python main.py
Traceback (most recent call last):
File “main.py”, line 4, in
from arithmetic_arranger import arithmetic_arranger
File “/home/runner/boilerplate-arithmetic-formatter-1/arithmetic_arranger.py”, line 2
def arithmetic_arranger(problem)
^
SyntaxError: invalid syntax
exit status 1

Could you link to your code on replit?

The tests on repl are just calling the functions… Unless you changed the function signatures, that isn’t the issue. I agree that seeing the code is necessary.

Sure, here you go:
https://replit.com/@dchris/boilerplate-arithmetic-formatter-1#arithmetic_arranger.py

You should not print anything inside of your function. You need to return the correct string from the function.

lol I don’t even know what that means…

You are using print. Don’t.

You are also using exit. Don’t.

The strings that you are printing must instead be returned.


Bad:

print("This is a string"); exit(0)

Good:

return "This is a string"

Side note - a exit value of zero is only for success, and a non-zero exit code is for failure.

ahhh ok, that makes sense. But will that solve the problem where I am not getting the problems as input?

I don’t know why you think you aren’t getting problems as input. Did you change the function signatures from what you were told to use?

I think that because I am getting an error on that line when I run the code. I didn’t change the function signatures (at least as far as I know, i’m not entirely sure what that means tbh).

You are probably getting errors because you are using exit to crash the program and you aren’t returning strings like the tests expect.

You also deleted the : at the end of the function signature at some point.

function my_function():
    return "This is a string"

That’s what it was, man I am bad at this!

It’s a complex thing. Learning complex things is hard and takes time!

Any idea why my solutions won’t pass (test 9/10)?

Your return statements are pretty complicated, but it looks Iike you are trying to return the solutions separately from the rest of the result. That can’t work. A function can only return once and then it immediately stops.

ok, that’s why then. thanks for all of your help

1 Like

In the following line, what exactly is happening with the solutions bit?
def arithmetic_arranger(problems, solutions = True):

I can get my program to toggle my solutions on and off in pycharm by setting a manual variable to t/f but I guess I don’t understand how to manipulate/handle that out of the above line?