Python Python Basics (2015) Python Data Types String Formatting

not 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
Alex Koumparos
Python Web Development Techdegree Student 35,918 Points

HI 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 your name into the placeholder. Assign this to the variable subject (so start with subject =).

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.