Seeming discrepancy in exercise requirements

I am working on the OCR exercise in Python. And there seems to be a discrepancy in the requirements. Test 17 indicates that a blank line should cause a comma in the output. But this “extra” line would seem to violate the requirement that the number of lines should be a multiple of 4.

Please help!

How many lines of input are in that test? Is it a multiple of 4?

Hi @jsmallt9,

I am not quite sure what “extra line” you are referring to? Is this test 17?:

def test_numbers_separated_by_empty_lines_are_recognized_lines_are_joined_by_commas(
        self,
    ):
        self.assertEqual(
            convert(
                [
                    "    _  _ ",
                    "  | _| _|",
                    "  ||_  _|",
                    "         ",
                    "    _  _ ",
                    "|_||_ |_ ",
                    "  | _||_|",
                    "         ",
                    " _  _  _ ",
                    "  ||_||_|",
                    "  ||_| _|",
                    "         ",
                ]
            ),
            "123,456,789",
        )

When I count the quoted lines, I get 12 — which is divisible by 4 (it should come out to 3 sets of number cells).

With the white space and the indentation, it can be hard to read. But you should only be concerned about the lines that are quoted — that is the input that is getting unpacked by your function — the rest of the whitespace is code formatting and is ignored by the Python interpreter.

I hope that clarifies things. :slightly_smiling_face:

If not, please past the code you’ve tried in a code block, and what error messages you are getting (if you are getting any) when the tests run, and we can troubleshoot from there.

Thanks for your quick reply.

I count 12 lines, too, a multiple of 4. But as the “def” says, "numbers_separated_by_empty_lines_are_joined_by_commas. And you can see the commas in the expected result.

I don’t see anything in the input which might be interpreted as an “empty” line.

So what specifically is it about the input that my code is supposed to recognize that a comma is needed?

Thanks for your reply.

See my reply to Bethany: http://forum.exercism.org/t/seeming-discrepancy-in-exercise-requirements/55309/4

The function name might be misleading you a bit. Don’t read too much into it. The 4th and 8th and 12th lines are blank lines while being the 4th line for the digits. It’s not an additional black line. But it is a blank line.

But the 4th line is always blank. And there are no commas in the solutions for the other tests with these blank 4th lines.

Is it the presence of more than 4 lines that demands the commas? If so, it would be nice if the instructions made that clear.

The instructions say,

If the grid has multiple rows of cells, the rows should be separated in the output with a "," .

Is that sufficient to explain the required behavior here?

Certainly! Thank you.