Python Python Basics (2015) Python Data Types String Formatting

name='ruby zhang' subject='Treehouse loves {}' subject.format(name)

Hi, can anyone tell me what's wrong with this task? The website tell me to make sure to use {} and .format
name='ruby zhang'
subject='Treehouse loves {}'

1 Answer

Alex Koumparos
Alex Koumparos
Python Web Development Techdegree Student 35,918 Points

Hi Yang,

You need to include the value in name in the value that gets assigned to subject.

In your code, you've assigned the text "Treehouse loves {}" to the variable subject (line2), but it never gets the contents of name.

In line 3 you are reading the contents of subject and formatting it with the contents of name, but not assigning the value you read into the variable.

What you need to do is perform the .format(name) piece on the code you have in line 2. If you're having trouble remembering exactly how to do this on the same line, refresh your memory by rewatching the relevant video: Strings.



Thank you Alex! You really solve my problem :)