laike9m / Python-Type-Challenges

Master Python typing (type hints) with interactive online exercises!

Home Page:https://python-type-challenges.zeabur.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add newline in `typealias` challenge

JCGoran opened this issue · comments

The following fails to work on the typealias challenge:

"""
TODO:

Create a new type called Vector, which is a list of float.
"""

type Vector = list[float]

with the error:

Error:
7:error: Statements must be separated by newlines or semicolons

This took me a second, and the solution that's accepted is in fact:

"""
TODO:

Create a new type called Vector, which is a list of float.
"""

type Vector = list[float]
 

Note the trailing newline (I had to add a space as well because the GH markdown parser seems to swallow it otherwise).
I haven't looked at the code, but I suspect it's concatenating the left and right code samples without adding a newline, so this could come as a surprise to some.

It would in general maybe be better to just strip both the LHS and the RHS of any trailing whitespace, and concatenate them with a newline in the middle, just to avoid issues with indentation and newlines.

Thanks for the bug report. I'll take a look.