- [Instructor] In this self-check exercise,
we'd like you to take advantage of string concatenation
and string repetition to create a concatenation
of your first and your last name
and then to use the repetition operator
to create a bar of asterisks that's the same length
as your concatenated name, and display that bar
above and below your name as well.
So go ahead and pause the video to give that a shot,
and then come back to see the results.
Okay, let's start out by assuming we have
a first name and a last name, Pam and Black,
and we're going to assign to name the string Pam
and we're going to concatenate
with that the string Black.
So if I go ahead and execute those,
I now have Pam space Black as the value of name,
and the next thing I'm going to do is define
a bar variable, which is just a single asterisk,
and let's repeat that by the length
of the newly concatenated name string.
So bar times equals len name is going to figure out
the proper number of characters in Pam space Black.
Repeat the asterisk that number of times
and store the result in bar,
and then finally we can go ahead
and display the bar, a new line, the name,
a new line, and the bar again,
and as you can see here indeed we get Pam Black
with the correct number of asterisks above and below.