I was trying out python -mtimeit
so I put python -mtimeit \"n = 0; while n < 10: pass\"
Then an invalid syntax error showed up. same with semicol
The selected answer superbly tackles the why, but not the question of how this can be worked around under any operating system (since windows cmd doesn't allow multi-line statements)
The answer is: exec
You have to nest any loops in an exec statement.
Examples: (Python 2)
python -c "i = 3; while i:print i; i-=1"
is a syntax error, while
python -c "i = 3; exec 'while i:print i;i-=1'"
works correctly.