Stack Overflow works best with JavaScript enabled
You can indent using tabs and spaces in Python. You should change your question to reflect that and mention what editor you are using.How you change this depends on your editor. '\t'. Indentation. This will automatically fix everything. your coworkers to find and share information. if you use sublime or any other editor which gives you the tool to replace text you can replace all tabs by four spaces from editor.I oddly ran into a similar issue with one of my .py files. Solution: your 'tab' before the problem line is spaces, 4, 6, or 8 spaces. Another way to fix this error is by selecting the entire code by pressing In case if you are using python IDLE, select all the code by pressing (Ctrl + A) and then go to Format >> Untabify Region Both of these are considered to be whitespaces when you code. It's more consistent across editors, resulting in fewer mismatches of this sort. hope it help others.it is because of using tabs and spaces for indenting code. To convert tab to space is really editor-dependent.On Emacs, for example, you can call the method 'untabify'.On command line, you can use a sed line (adapt the number of spaces to whatever pleases you):What I did when the same error popped up: Select everything (I recently had the same problem and found out that I just needed to convert the .py file's charset to BTW, I used 4-space tabs all the time, so the problem wasn't caused by them.I had this problem.
)@Lennart Regebro, I mean using spaces at all. I do use them but unconsciously, tabs seem better to me. If I see any noise at the start of the line, I know that there're one or more extra spaces. (above python 2.5) Of course \t is actually a TAB token whereas the described method generates spaces. One way to combat this error is to go to the settings of your text editor and enable the “convert tabs to spaces” feature which automatically replaces … Some editors provide you of tools to help with the problem by:For example, if you are using Stani's Python editor you can configure it to do it on saving.If you are using ActiveState Komodo you have a tool to 'tabify' your code. When you set the tabsize to 2. In Notepad++ it did not work.After adding the code lines and saving, I got the same error. Featured on Meta
From the Python documentation: 2.1.8. Stack Overflow for Teams is a private, secure spot for you and
Idle can untabify the whole region and fixes the problem (Just choose Untabify from Menu Format).not to mention that if collaborators on this code that are using PEP8 will encounter the same error I would be glad if I could get some overall tips on my code, if I have done a lot of mistakes I would be happy to hear.Note: The reason for 8 spaces for tabs is so that you immediately notice when tabs have been inserted unintentionally - such as when copying and pasting from example code that uses tabs instead of spaces.When using the sublime text editor, I was able to select the segment of my code that was giving me the Generally, people prefer indenting with space.