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 trialJonatan Spahn
6,362 PointsCode Challenge Basic Python regarding strings
Why is it that in the python shell you can do the following code name = "John" subject = "Hi my name is {}" print(subject.format(name)) and it returns "Hi my name is John"
but on the code challenge you have to add the .format after the "" such as name = "john" subject = "Treehouse loves {}".format(name) print(subject) which returns "Treehouse loves john"
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! It has to do with meeting the exacting requirements of the challenge. The challenge requires that the ending value stored in subject
will be the properly formatted string. In your workspace, you've added the formatting in the print statement, but the formatting still isn't saved in the subject
variable.
If you don't do the format on the same line with the subject variable assignment, then the value stored in subject
will not be what the checker is looking for and count it incorrect.
Hope this clarifies things!