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 trial

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

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

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 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.

Cheers

Alex

Thank you Alex! You really solve my problem :)