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

selcuk baran
selcuk baran
3,526 Points

format

how to use format function

strings.py
name='selcuk'
subject= print('Treehouse loves {} '.format(name))

3 Answers

Michael Hess
Michael Hess
24,512 Points

Hi Selcuk,

You don't need to use print().

Try:

name='selcuk'
subject= 'Treehouse loves {} '.format(name)
Ryan S
Ryan S
27,276 Points

Hi Selcuk,

You are very close. But the challenge is not asking you to print anything. So if you take the print() function out then it should work. Also, take note of the space you left between the curly braces and the end quotation. The challenges can be sensitive about things like that.

Also, as a side note, the way you used the print() function by assigning it to a variable won't necessarily throw an error but it won't work as you might think. It will still print the contents, but "subject" will have a value equal to None. You'd be better off assigning the formatted string to the variable "subject", then simply use print(subject).

Good luck.