Closed FranckCHAMBON closed 2 years ago
I read again the code of the function test_passes, and I think not only the last line should be right stripped, but all lines.
With this in mind, the last line of this function shouldn't be :
stdout == reference.stdout.strip())
but rather
import itertools
#...
all(line_reference.rstrip() == line_submitted.rstrip()
for line_reference, line_submitted in
itertools.zip_longuest(reference.stdout.split('\n'), stdout.split('\n'), fillvalue = '')
There is interest in rstrip all lines instead of only the last one. For example, this code will fail to pass test, but it should.
# code
for i in range(3):
print(i * i, end= " ")
print("done!")
stdout
0 1 4
done!
Why ? There's an extra whitespace at the end of the first line. This extra whitespace should, imho, be stripped just like any ones at the end of a line. This will make easier code for beginners, and won't affect the meaning of a problem.
This issue was opened in the wrong repository, transferring to site/.
In function
test_passes
,strip
is used at lines 64 and 72:Instead of
strip
method, therstrip
is enough for the desired job, and it will let intact output like:or rather more important an awaited output like
Regards,