Arithmetic_arranger and replit

Hi, I have coded the whole program in the platform used during the Python programing course and it’s working perfectly but when I try to run it in replit i get the error:
sh: 1 : run: not found

I just can’t get the program to run on replit. I really dont understand why and it also rises the question of why do we practice in one console and then are expected to code in another one which is completely foreign to us?. It bugs my mind sorry, I’m a bit frustrated :pensive:

Hi there,

The tests will run automatically whenever you hit the “run” button. Alternatively you may also try to run the tests by inputting pytest in the console.

Try to check this:
My terminal does not run and I am stuck with sh: 1: Use: not found problem in console - #3 by tcin4707 - Replit Help - Replit Ask

So I must have touched something in the main_py or test_module because I solved it by creating another instance of the whole arithmetic_arranger replit. Now it runs but the program doesn’t do what it should. I don’t know if I should continue here or delete the post and create a new one. because I tested the code and it’s bulletproof, it works with all the test cases in a different compiler

What error do you get? Please share a link to the replit.

The previous error sounds like the “Run” button was not configured to run python. You need to edit your .replit file and where it says “run = Command” change it to

run = "python3"

This is my replit

This is my code working on the compiler we use during the course

I’m sorry I don’t know what’s wrong. I mostly feel there is no point to teach a course with a dumbed down compiler and then evaluate in a completely different complex system which we had no instruction in. Please don’t take it as rant, take it as something to improve in the course. I’m a teacher and this is classic “the problems in the final exam will be the same as during the course” unless their are not :roll_eyes:

I’m looking into it, but first:

In .replit you have:

run = "pytest"

This is incorrect, this should be

run = "python3"

Once that’s fixed you have some errors you can troubleshoot:

___________________ test_template[test_two_problems_arrangement1] ___________________

arguments = [['3801 - 2', '123 + 49']]
expected_output = '  3801      123\n-    2    +  49\n------    -----'
fail_message = 'Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]'

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

/home/runner/boilerplate-arithmetic-formatter-1/ AssertionError

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!

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

Looks like you just have some spacing issues to sort out.

But why is it doing this? The code works fine in a different compiler. And I’m sorry but I’m too new to this and the information dump in the console is not very clear at all.

Please I don’t want to sound ungratefull nor anything. I know you are going out of your way to help but we are talking different languages

It doesn’t. You aren’t producing the exact results required

I totally understand, you learned in this one environment, now you are expected to perform in another environment and it’s not even working and you need to troubleshoot it before you even begin what you’re supposed to do.

All I can say is, sometimes that happens. You’ll learn something about replit, which could be very useful going forward and you’ll learn more and be able to solve these problems in the future easily. It’s always going to be like this.

In this case, the Run button did not get configured correctly. We just need to tell the environment what to do when you hit the run button. We do this by editing the .replit file.

You want the Run button to run the Python interpreter:

run = "python3

You want the Python interpreter to read the code in

run = "python3"

That is going to run a bunch of tests on your code.

I have changed the run line and it’s exactly the same.

I can’t upload more than one img per post so excuse me for the spam. I’m sure it has to be something about the tester formating being incompatible with what i’m doing.

Look, this is what i get from the first problem, a bunch of unarranged numbers that i have no clue on how they get generated like that.

That error means you aren’t producing the required output. Specifically, you have too many extra spaces at the end of every line.

and this is what happens if I take away a set of

It generates what it’s supposed to, but there is still more noise, generating an extra unintended error message

Please read my previous reply about reading these assertion errors. They look confusing but once you learn to read them, they are telling you all that you need to know.

Your results have to be exactly correct down to the last character, otherwise the tests cannot recognize the results as correct.

This exact issue was actually my first post on the forum and you helped me with it, haha

1 Like

Woah! Don’t touch the test cases at all! That will make things more confusing!!