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 trialamarjeet Suryawanshi
412 Pointsnot getting exactly what to do in this
i tried this code many times but not getting whats the actual error
name = "Anurag"
subject = ("Treehouse loves Anurag". format ("anurag"))
1 Answer
Alex Koumparos
Python Development Techdegree Student 36,887 PointsHI Amarjeet,
Let's look at the challenge text that tells us exactly what we need to do:
OK, now use
.format()
on the string"Treehouse loves {}"
to put yourname
into the placeholder. Assign this to the variablesubject
(so start withsubject =
).
And let's compare to your code. The instructions say to use the string "Treehouse loves {}". Your string is "Treehouse loves Anurag".
Next, we need to use the format() method. The instructions say to use the name
variable. You have used the string literal 'Anurag'.
In addition, you've added some spaces where they don't belong. For example, format
is a method on a string. The syntax for methods is the object name, then a period, then the method name. No spaces. Similarly, you've added a space between the method name and the opening parenthesis. The Python parser will accept this latter space, but it does violate the Python style guide.
Hope that clears everything up.
Cheers
Alex