3

In my bash Terminal (Mac OS) I type the following:

python -c 'import time; while True: time.sleep(5)'

And a SyntaxError is thrown.

Why should this be? Both of the following examples run:

python -c 'import time; time.sleep(5)'
python -c 'while True: pass'

so not sure why this is throwing an error.

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
Sam Redway
  • 7,605
  • 2
  • 27
  • 41
  • (As far as I can tell,) Python won't allow two or more colons (":") on one physical code line. It will allow a colon to be on the same line as one or more semicolons (";"), as long as the colon occurs first, before any of the semicolons. – J-L Nov 14 '18 at 22:50

0 Answers0