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


Josh Bennett
Josh Bennett
15,258 Points

.lower() method is causing the function to skip to else:

Here is my code

def lumberjack(name):
    if name.lower() == 'Josh':
        print("Josh is a lumberjack and he's ok!")
        print("{} sleeps all night and {} works all day!".format(name, name))


When I remove the .lower() method, it works perfectly. I have tried .upper() as well and had the same issue. It is causing it to skip down and print the else: statement (correctly, I might add, .format() is all good)

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hey Josh,

It will jump to the else clause, because you are comparing it to "Josh", which has an upper-case "J", so it will never pass toLowerCase(), as this will check for an all lower-cased version of "josh". You need to change "Josh" to "josh" in the conditional logic and it should work fine.

Keep coding! :) :dizzy: