I'm getting IndentationError: unexpected indent
even though I wrote the code exactly as shown in the book (Learn Pythhon the hard way)
I'm sure that I'm using exactly four spaces to indent the lines which come after "def".
I am using Python 2.7 on Windows 7.
Here's the error I get in PowerShell:
PS C:\Users\Kiedis\python> python ex25.py
File "ex25.py", line 3
return sorted(words)
^
IndentationError: unexpected indent
And here are the first three lines of my code:
def sort_words(words):
"""Sorts the words"""
return sorted(words)
You are mixing tabs and spaces anyway; run your script with:
python -tt ex25.py
to detect where the error lies.
Then configure your editor to only use spaces for indentation, and re-indent your file. See How does one configure Notepad++ to use spaces instead of tabs?