why such a simple program like this is not getting compiled in Python : <p>I am a bit new to python and </p>

<pre><code>    import serial
    import time
    ser = serial.Serial('COM3', 9600, timeout=0)

    while 1:
     try:
      print ser.readline()
      time.sleep(1)
     except ser.SerialTimeoutException:
      print('Data could not be read')
      time.sleep(1)
</code></pre>

<p>I installed pyserial. Why such a simple program like this is giving "invalid syntax" error at the line ser.readline(). Why has been python designed like this that it always makes beginners life difficult. Even here at stackoverflow why syntaxing code is so difficult? everyline has to be indented here.Why cant a simple <code></code> do the job here.Well this is all together a different topic but why such a simple python program is creating errors????? </p>
