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 trialJordan Bester
4,752 Pointshow come my python shell will not show my lumberjack?
def lumberjack(name): if name.lower () == 'jordan': print ("Jordan is a lumberjack!") else: print ("{} sleeps all night and {} works all day!".format(name, name))
lumberjack{"Jordan"}
3 Answers
Nathan Tallack
22,160 PointsI'd say there is a pretty good chance that it is the fact that you are passing your parameter to your function by putting it inside curly braces rather than brackets on the last line.
Also, double check your indenting of your code block matches the code below. I can't confirm that because you pasted your code in without markdown formatting.
def lumberjack(name):
if name.lower () == 'jordan':
print ("Jordan is a lumberjack!")
else:
print ("{} sleeps all night and {} works all day!".format(name, name))
lumberjack("Jordan")
Jordan Bester
4,752 Pointsdef hows_the_parrot(): print("He's pining for the fjords!")
hows_the_parrot()
def lumberjack(name): if name.lower() == 'jordan': print("Jordan is a lumberjack!") else: print("{} sleeps all night and {} works all day!".format(name, name))
lumberjack("Jordan")
this is how I had it originally set up but it seems to not be working for me :(
Jordan Bester
4,752 Pointswith the proper formatting of course
Sean T. Unwin
28,690 PointsIf you need help with inserting code into your posts, please see: https://teamtreehouse.com/forum/posting-code-to-the-forum
:)
Sean T. Unwin
28,690 PointsI copied your code, formatted it (as seen below) and it ran fine.
If you're having trouble then perhaps it is an issue with correct formatting (indentation, for example). Please see my previous comment about how to post code and show us how you have written it.
def hows_the_parrot():
print("He's pining for the fjords!")
hows_the_parrot()
def lumberjack(name):
if name.lower() == 'jordan':
print("Jordan is a lumberjack!")
else:
print("{} sleeps all night and {} works all day!".format(name, name))
lumberjack("Jordan")
## Output:
# He's pining for the fjords!
# Jordan is a lumberjack!
Sean T. Unwin
28,690 PointsBe sure you are using Python3 for your interpreter.
Some systems, like linux for example, may have Python 2, as well as, Python 3 installed.
To test for this, inside your terminal type: python -v
. This will let you know the version of Python installed. If the result is similar to 2.x.x
, then try python3
. This should result in something similar to, 3.x.x
.
So that means when in the terminal on your own computer use python3
instead of simply python
when running a script.
Sean T. Unwin
28,690 PointsSean T. Unwin
28,690 PointsGood eye as well as a helpful recommendation, Nathan. :)