0

A student made the mistake of adding a colon after print, before the open bracket. To my surprise, this didn't result in a syntax error, but it suppressed the output. For instance, code like this in interactive mode doesn't show anything:

print:("this is a test")
len:("this is a test")
sum:([1,2,3,4])

It is only when using such an expression as part of another expression that it shows a syntax error, like:

>>> print(len:("this is a test"))
  File "<stdin>", line 1
    print(len:("this is a test"))
             ^
SyntaxError: invalid syntax

Why would it be that the former examples don't show a syntax error?

Marko
  • 370
  • 2
  • 7

0 Answers0