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

how to use .formate() method

I can't complete my task

strings.py
name="MOON"
subject="Treehouse loves {}.formate(name)"
Oliver Small
Oliver Small
12,578 Points

I think you may be spelling it wrong, it should be .format(name). You also need to close the " before you use it. so it would be

subject = "Treehouse loves {}".format(name)

1 Answer

Ben Reynolds
Ben Reynolds
35,170 Points
  1. There's a typo, "formate" should be "format"
  2. The format method gets added at the end of the string, after the closing quote mark. Right now you have the whole thing enclosed in quotes so it's treating the format code like plain text.