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

I keep getting an Indentation Error : unexpected indent

This is the code that i am using

name = input(" what is your name? ")

if name == "kenneth": print(name + " is a lumberjack ") else: print(name + " works all day and night ")

and i keep getting an error saying

line 3 if name == "kenneth",

Indentation Error : unexpected indent

any help to correct this would help.

Thanks for all your help and time guys

2 Answers

Michael Joyce
Michael Joyce
6,214 Points

You need to indent your print statement under the first if and the second print under else like below. You might also want to add a .lower() on the end of input(" what is your name? ") if you are checking to see if kenneth is lowercase.

Try this out!

name = input(" what is your name? ")

if name == "kenneth": 
    print(name + " is a lumberjack ") 
else: 
    print(name + " works all day and night ")

Thanks Michael it worked and i understood where its going wrong

Regards Gladdy