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 trialGary Gibson
5,011 PointsError Despite Copying Exactly
Here is my code:
def lumberjack(name):
if name.lower() == 'gary':
print("Gary's a lumberjack and he's OK!")
else:
print("{} sleeps all night and {} works all day!".format(name))
lumberjack("gary")
And here is the error I'm getting in the shell:
treehouse:~/workspace$ python functions.py
File "functions.py", line 10
print("{} sleeps all night and {} works all day!".format(name))
^
TabError: inconsistent use of tabs and spaces in indentation
[MOD: added markdown code block formating -cf]
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsYour first print uses 8 spaces, your second print uses 2 tabs. Best to use same for both, and best to use spaces
Roberto Núñez
4,256 PointsJajaja I think is about the fact that out dear professor forgot to put .format(name,name) so after half an hour trying to make it work, I give up and press play... then he corrects it. Lesson learned wait until it works for HIM first. Learned a lot about inputing and playing with inputs in the process LOL.
Chris Freeman
Treehouse Moderator 68,441 PointsYes, it's best to wait for the working version. Treehouse has received much positive feedback on seeing the instructors make and correct basic mistakes in their code. Many lessons are in the mistakes.