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
sagar goyal
565 Pointspython 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
jag
18,266 Pointsdef 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.
sagar goyal
565 PointsThe program is not even opening it just doesn't say anything
jag
18,266 Pointssagar goyal
565 Pointsjag
18,266 PointsPython 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")
sagar goyal
565 PointsThank you so much