<p>我是Python新手,目前正在学习控制流命令,如<code>if</code>、<code>else</code>,等等</p>
<p><code>if</code>语句工作正常,但是当我编写<code>else</code>或<code>elif</code>命令时,解释器会给出语法错误。我使用的是Python3.2.1,问题出现在它的本机解释器和IDLE中。</p>
<p>我按照书中的说明来做。如您所见,<code>elif</code>和<code>else</code>给出了<em>无效语法</em>。</p>
<pre><code>>> number=23
>> guess = input('Enter a number : ')
>> if guess == number:
>> print('Congratulations! You guessed it.')
>> elif guess < number:
**( It is giving me 'Invalid Syntax')**
>> else:
**( It is also giving me 'Invalid syntax')**
</code></pre>
<p>为什么会这样?我在IDLE和交互式python中都遇到了问题。我希望语法正确。</p>
<p><img src="https://i.stack.imgur.com/fQmiH.jpg" alt="enter image description here"/></p>