Helo, I find something odd in the Diamond exercises:
What the exercise describes:
----A----
—B-B—
–C—C–
-D-----D-
E-------E
-D-----D-
–C—C–
—B-B—
----A----
What the exercise actually expects:
[" A “, " B B “, “C C”, " B B “, " A “][”–A–”,-”-B-B-”,-“C—C”,-“-B-B-”,-“–A–”]
(with spaces I know)
Based on the task description I would had expected a single string to be submitted, with \n breaks, but the task actually wanted lists, which are not Diamond shaped upon printing at all.
Is it my broken English or is the task really not alligned between the description (readme) and the test expectations?
I submitted a solution which worked in my pycharm but the online Exercism does not accept it. (requested mentoring)
Sorry if this is something trivial I am missing, I am new here.
It sounds like either something is broken or you’re writing code but not actually running the unit tests in your local environment! See Testing on the Python track | Exercism's Docs
I can only repeat that on my pycharm the tests succeed and I tested and submitted exercises this way about two dozen times by now and they worked. For some reason and I tried to resubmit it this one do not.
You’re running pytest locally and it passes but the tests on the website fail? Can you share the test failures message from the website (using a codeblock and NOT an image)?
We received the following error when we ran your code:
.usr.local.lib.python3.11.site-packages._pytest.python.py:618: in _importtestmodule
mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
.usr.local.lib.python3.11.site-packages._pytest.pathlib.py:533: in import_path
importlib.import_module(module_name)
.usr.local.lib.python3.11.importlib.__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1204: in _gcd_import
???
<frozen importlib._bootstrap>:1176: in _find_and_load
???
<frozen importlib._bootstrap>:1147: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:690: in _load_unlocked
???
.usr.local.lib.python3.11.site-packages._pytest.assertion.rewrite.py:168: in exec_module
exec(co, module.__dict__)
.mnt.exercism-iteration.diamond_test.py:7: in <module>
from diamond import (
E File ".mnt.exercism-iteration.diamond.py", line 6
E diamond = f"{" " * where}A{" " * where}\n"
E ^
E SyntaxError: f-string: expecting '}'
It uses the double quotes (") for the string and for the {} expressions inside the string.
This feature is “Quote Reuse” and has been added to Python in version 3.12 (see What’s new).
But Exercism’s test runner uses Python 3.11, so you get an error when you submit it to Exercism.