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

ok, whatΒ΄s wrong?

help is needed

strings.py
name = "jose {} carvalho"
name.format("antonio")
subject = "Treehouse loves {}"
subject = subject.format(name.format("antonio"))

2 Answers

Manish Giri
Manish Giri
16,266 Points

If you place { } in a string, think of it as a placeholder for a string value you want to plug in yourself.

Example - "Hello {}".format("world") would print "Hello world".

So, if your subject is - "Treehouse loves {}", then in your.format()`, you just need to use your name.

Also, I don't think the challenge specifically asks you to use .format() on the name variable too, so you can just place your name direclty in name, and it should work fine.

Please can you write it down I have tried this for over an hour and I still do not understand

Thank you Manish