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 Splitting and Joining

Ernesto Ramos
Ernesto Ramos
3,098 Points

What am i using {}.format() before .join() for?

At 5:23 in the video Kenneth used .join and later used both together, still getting the same result.

2 Answers

Jeffery Austin
Jeffery Austin
8,128 Points

I am not sure if I understand your question. {} is a placeholder inside a string. .format() allows you to insert something into that placeholder, and .join() allows you to join a list into a string with whatever you want to join that list with. In the video he is showing two examples. One example joins a string with a joined string, the other example is showing a string that has a placeholder and is using format to insert joined string into the placeholder {}. He is just showing that you can call a function inside a function. This allows for some pretty powerful functionality.

John Goldring
John Goldring
634 Points

Ernesto, I was wondering why he used {} as well to get the same result and from what I'm gathering... A lot of things in Python (and other languages) there's so many different ways you can write code and get the same result. I'm guessing he's just showing us 2 different ways you can write out that result.