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 functions

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

    lumberjack("k")

I made this function by seeing the video but in the video the same function is working but when i made it and tried running it it didn't work

4 Answers

def lumberjack(name): 
    if name.lower() == 'k': 
        print("kenneth's a lumber and he's ok!") 
    else: 
        print("{0} sleeps all night and {0} works all day!".format(name))

lumberjack("Ke")

{} {} would need two args unless you define that those placeholders will use the same argument.

The program is not even opening it just doesn't say anything

Python has strict rules about spaces and tabs, you are adding extra spaces or tabs resulting in nothing showing up.

Your code with spaces = no results

def lumberjack(name) :
        if name.lower() == 'kenneth':
             print("kenneth's a lumber and he's ok!")
        else:
             print("{0} sleeps all night and {0} works all day!".format(name))

        lumberjack("k")

Code without extra spaces = two results

def lumberjack(name): 
    if name.lower() == 'k': 
        print("kenneth's a lumber and he's ok!") 
    else: 
        print("{0} sleeps all night and {0} works all day!".format(name))

lumberjack("K")
lumberjack("Ke")

Thank you so much