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 trialPeter Jonsson
1,857 PointsFormat works but I do not understand what Im doing really. And what is the advantage compared to ordinary print?
print (" well thanks anyways, {}!".format(user_name))
1 Answer
Steven Parker
231,269 PointsFrom my perspective, the main advantage is in using tokens in the template string to represent where variables are to be displayed along with literal text.
Later, you will learn another technique called format strings, or "f-strings" that takes this concept to an even more advanced level. Here's a preview:
print (" well thanks anyways, {}!".format(user_name)) // using format
print(f" well thanks anyways, {user_name}!") // same using f-string