python IndentationError: expected an indented block

>>> a=[1,2,3,4,5]
>>> a
[1, 2, 3, 4, 5]
>>> for i in a :
... print i
  File "<stdin>", line 2
    print i
        ^

IndentationError: expected an indented block

剛開始學python用for循環時就撞牆,感覺自己的代碼和書上的完全是一樣的,結果就是報expected an indented block錯誤,偏偏英語有不好,就是沒看懂這段話。唉被催呀。後來一百度才知道是縮進問題。其實就是for循環下一句忘記了按tab建。

>>> a=[1,2,3,4,5]
>>> a
[1, 2, 3, 4, 5]
>>> for i in a :

...     print i

python繼續中。。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章