Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indentation Error in Python [duplicate]

I can't compile because of this part in my code:

if command == 'HOWMANY':
    opcodegroupr = "A0"
    opcoder = "85"
elif command == 'IDENTIFY':
    opcodegroupr = "A0"
    opcoder = "81"

I have this error:

Sorry: IndentationError: ('unindent does not match any outer indentation level', ('wsn.py', 1016, 30, "\t\telif command == 'IDENTIFY':\n"))

But I don't see any indentation error. What can be the problem?

like image 437
sharkbait Avatar asked Feb 20 '13 11:02

sharkbait


2 Answers

You are mixing tabs and spaces.

Find the exact location with:

python -tt yourscript.py

and replace all tabs with spaces. You really want to configure your text editor to only insert spaces for tabs as well.

like image 147
Martijn Pieters Avatar answered Sep 20 '22 14:09

Martijn Pieters


In doubt change your editor to make tabs and spaces visible. It is also a very good idea to have the editor resolve all tabs to 4 spaces.

like image 22
Udo Klein Avatar answered Sep 22 '22 14:09

Udo Klein