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 trialRajanand Ilangovan
1,835 PointsPython string format
I get expected output in python console but when I check the code challenge task I get error. Can anyone tell me what am I missing here?
Thanks!
name = 'Rajanand Ilangovan'
treehouse = 'Tree'+'house'
email_greeting = ('{} loves {}'.format(treehouse,name))
print email_greeting
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsHii Rajanand, Your code actually passes for me, provided you correct the syntax error (for Python 3.x) by add the missing parentheses on the print
statement, or if you comment out the print statement which is not needed for the challenge.
Dan Johnson
40,533 PointsAs of Python 3, print is treated just like any other function instead of a keyword, so you need the parentheses to call it:
print(email_greeting)
If you were checking with an older version of Python your code would have ran fine.
Rajanand Ilangovan
1,835 PointsThank you, Dan!
Rajanand Ilangovan
1,835 PointsRajanand Ilangovan
1,835 PointsThank you, Chris!