>> So previously, we saw how we could take
a couple of strings and combine them
together by using that literal plus operator.
Now, we've already seen this slide and if you take
a look at the code in particular that fourth line,
what you're going to notice there is there's a lot going on,
that I've got that little plus right there in the middle,
with my string literal,
and then I've got another plus here,
and another string literal,
and another plus here,
and another string literal.
This could get on weirdly pretty quickly,
and this is not even
taking into account that we might want to be calling capitalize,
or upper, or lower,
or some of those other helper functions that we might have,
and our codes are just going to keep getting longer,
and longer, and longer.
So let's try and simplify this a little bit.
This is where our format strings come into play.
Now, what we can do is that little output that we see up at the
top where again we're calling
that plus sign that we've already seen,
or we can streamline this by using placeholders.
Now, each one of these outputs that
you see up here on the slide is
going to give us the exact same string.
We're just going to do it slightly differently.
So the first one,
what we're doing here is we're going in and
we're putting in place holders with those curly braces.
Now, the way that this works is it's going to be based on
the order in which we specify the parameters.
So that first one there,
that's going to be first name in my case,
and that second one,
that is going to be last name.
Now, if we wanted to specify it,
what we can do instead is we can use the zero,
and the one which then allows us to
specify the first and the second respectively.
Remember, that counting will start with zero,
so that zero is going to be the first item,
and the one is going to be the second item.
Now, in my example up here,
it's not going to make a difference,
that both of them are the exact same.
But if I need to potentially reuse
the exact same string somewhere else
or maybe I just want to document it, show hey,
this is going to be the first, this is going to be for the second,
this is going to be for the third,
then I could go ahead and put in that zero,
the one, and then maybe a two later on as well.
Now, the last example that I want to highlight here,
and I want to make sure that I point out the fact,
that was not what I wanted,
I wanted that, there we go.
I want to make sure that I point out the fact that this is
only available in Python 3.
So if you're doing anything that needs to run in Python 2,
this last example is not going to work,
but it will work in Python 3.
That is where I put in f right at the very beginning,
f being for format,
and now what I'm able to do and I love this functionality,
is I'm able to now just use
my variable names right in line with everything else.
This is my preferred method
whenever I'm doing string concatenation,
because it's nice, it's clear, it's self-documenting,
you always want your code to be self-documenting,
and when somebody comes back assuming that they
understand the little f at the beginning,
it's very easy for them to go, "Oh,
that's going to be my first name,
and that is going to be my last name."
Let's see how all of this works
inside of code in our next little video.