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 trialWilliam Heimann
1,764 Pointspython basics, strings.py, what am I doing wrong?
I can't seem to figure out where my mistake is. I have looked at the video and the notes a few times and still it says I'm wrong. I put the code into the console on workspaces and it seemed to work. where is my mistake?
name = "Will"
subject = "Treehouse loves {}."
subject.format(name)
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYou are very close. This challenge wants the format()
on the same line. Also be sure the string is correct (no period at the end)
name = "Will"
subject = "Treehouse loves {}".format(name)
William Heimann
1,764 PointsWilliam Heimann
1,764 Pointsok thank you for the help. I originally didn't have the period but after reading a few other posts I thought that might fix it. One more question, the challenge wants the .format on the same line but it worked in the console when written in 2 lines, so which way is correct in real world application?
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsIn real code both are accepted. In creating the challenges sometimes the graders are overly specific to verify you learn a certain style.
In a later challenge, the following style of putting them on two lines is accepted:
Which you choose depends on what makes the code easiest to read.