Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialElisa Huertas
274 PointsWhat are the guidelines for indentation in python? I just got this error "inconsistent use of tabs and spaces"
I see in Craig's video that spaces are set to 4. but I will also appreciate some feedback on how to approach these errors
2 Answers
John Goodwin
17,921 PointsHi Elisa,
That error happens on here sometimes when one line is tabbed while others are spaces. Sometimes I have to find the same code somewhere and copy/paste it to get past the challenge. In Python, 4 spaces is the standard, but I believe it's more about consistency rather than the exact number of spaces.
r h
68,552 PointsIf you are mixing tabs and spaces you are going to have to rely on a text editor to correct the mismatches, because otherwise they're invisible to your naked eye and workspaces doesn't have a prettify command.
If you get completely stuck on workspaces (there is a clickable option in the lower right to change to either tabs or spaces. Choose spaces. And you can set the number of spaces by clicking the number following "spaces" and setting it to a number), you can always install microsoft visual studio code and use it to format your code. You will need to install the "python" plugin package. Visual Studio Code too has the option in the lower right of the window to set up either spacing or tabs (choose spaces: 4) and then you can highlight the code and right click and choose "Format Selection". That will prettify your code and set up the correct spacing.
You can also do this in Atom (http://atom.io) very easily: follow the instructions here: https://stackoverflow.com/questions/41848002/how-to-replace-tabs-with-spaces-in-atom
Setting up a third party text editor and not relying on workspaces will be a challenge, but the benefits are immense. You will enjoy working in a text editor much more than working in work spaces. You'll get amazing shortcuts, code completion, and lots of ability to prettify code and all that. Atom is very good but these days I prefer Visual Studio Code because of its code completion abilities.
Elisa Huertas
274 PointsThank you for your feedback Ryan! I'll try your suggestions later on. At the moment I'm only following the tutorials so I think I'll get by with the current tools
Elisa Huertas
274 PointsElisa Huertas
274 Pointsthank you for you feedback John