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
Viraj Cho
495 PointsWhy am I getting an error?
def hows_the_parrot():
print("He's pining for the fjords!")
hows_the_parrot()
def lumberjack(name):
if name.lower() == 'maulik':
print("Maulik is a lumberjack and he's OK!")
else:
print("{} sleeps all night and {} works all day!".format(name))
lumberjack("Maulik")
lumberjack("Prajyot")
Moderator edited: Markdown added so that code renders properly in the forums.
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! The reason you're getting an error is that you have not one but two placeholders in the string inside your else statement, but you've only supplied one variable to format it with.
You wrote:
print("{} sleeps all night and {} works all day!".format(name))
But that should be:
print("{} sleeps all night and {} works all day!".format(name, name))
#note that we give name here twice so that both {} will contain the value of a variable
Hope this helps!
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsWhat error are you getting?
Hard to tell why because you didn't format the code example, but my best guess would be that you have not indented your code correctly