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 trial

Python Python Basics Types and Branching Comparisons

IndentationError: unindent does not match any outer indentation level

I have my code exactly like the way it's in the video. Maybe I'm being overly dramatic as I did spend half an hour reviewing the code and repeating the video to see if this would change anything but nothing seems to change the fact that the code mistakes spaces and tabs for whatever reason

That's how I have my code and the problem seems to be print("you should TOTALLY learn python, {}!".format(first_name))

first_name = input("what is your first name?   ")
print("Hello,", first_name)
if first_name == "craig":
    print(first_name, "is becoming a better person")
elif first_name == "hugo":
    print(first_name, "is learning with fellow students in the Community! Me too")
else:
    age - int(input("how old are you  "))
    if age <= 6:
        print("wow you're {}! if you're confident with your reading already...".format(age))
    print("you should TOTALLY learn python, {}!".format(first_name))
print("have a great day {}!".format(first_name))

2 Answers

Steven Parker
Steven Parker
231,268 Points

Other than the minus sign (-) on line 8 which was probably intended to be an assignment operator (=), this code seems to be OK. But something that might not have come across in copying it here might be a mix of tabs and spaces.

Python will work with either, but it is important for the whole file to be consistent. Tabs on some lines and spaces on others could possibly cause this issue. Check for that.

Steven Parker
Steven Parker
231,268 Points

Markdown formatting translates tabs into spaces, so regardless how it was entered the code shown above is indented with consistent spacing. My suggestion is to copy that code and paste it into the editor to create a new file. If it runs without causing the error you have identified the issue.

if you don't mind, how would I check for that. I tried searching google and what came up is a built in string called isspace. Due to website being the only current way that I'm learning, I don't know how to use that right now