IndentationError: unexpected indent
本に示されているとおりにコードを書いたにもかかわらず、私は取得しています( http://learnpythonthehardway.org/book/ex25.html)
「def」の後の行をインデントするために、正確に 4 つのスペースを使用していると確信しています。
Windows 7 で Python 2.7 を使用する
powershell で表示されるエラーは次のとおりです。
PS C:\Users\Kiedis\python> python ex25.py
File "ex25.py", line 3
return sorted(words)
^
IndentationError: unexpected indent
これが私のコードの最初の 3 行です。
def sort_words(words):
"""Sorts the words"""
return sorted(words)