Welcome back.
Let's try and do an exercise to tie everything that we've learned up until now.
Together, we're going to create a password checker.
Now, while we want to do is to create some sort of an input that we're going to ask.
So we're going to use the input function and here we're going to ask for a username.
Then we're going to ask for another input.
It's going to be the password.
And then at the end, with the input we want to print.
Something, the lines of password, and then we'll have maybe the actual password in here and it will
say is another variable here long.
So what we want to do is the password and then maybe the password.
So that let's say we printed our username Jayjay, and then we give it a password of secret.
Well, we should print the password.
Secret is one, two, three, four, five, six letters long.
Now, obviously, we don't want to show or display the password, maybe for security reasons, so we
want to convert the secret to one, two, three, four, five, six, two stars.
So your task is to convert these two inputs.
And, you know, let's also do a greeting where we say the username here, so we're going to say, hey,
J.J..
Your password.
Which will be marked in a star is six letters long now, one neat trick here that you haven't learned
yet and you might want to use here is this they can do with strings.
I can go Star Times.
Make sure that the star is a string, multiply it by 10, and if I print this out.
I get 10 stars, so you may want to use this functionality when we're doing this.
All right, pause the video, give it a go, if you can remember, the goal is to print the username
and have the password blocked with how many characters the password is.
All right, pause the video, if not, I'm going to get going with the answer.
So the first thing we're going to try and do is I'm going to create two inputs.
So the first one, I'm going to get the user name, going to assign it to the variable user name and
it's going to say, what is your username?
Then the second one will be the password.
And the password, well, we'll say, what is your password?
And although this is a simple example, this is something that you will see with other big websites
like Instagram or maybe Netflix when you're logging in.
So now that I've stored this information into a variable, I can use it right, I can print and we'll
do an F string to make our lives easier.
So I've added the F here.
And what we'll do is this will say.
Username.
Your password.
And we'll add the password here.
Is and then we'll add.
Another variable here.
Which is the password length.
So how are we going to calculate that?
Well, let's try something here.
Let's see if I can use the length function and in here, do password.
Let's see what happens here.
What is my username?
Let's go with Andre.
What is my password, let's just type in secret here.
And I get Andre your password.
Well, I can't speak English properly, my password secret is six well, six what let's write six letters
long.
Awesome.
So this is working because with an F string, I can create or add a python expression in here using
the length password, but there's an issue here, right?
We don't want to actually print out secret.
We want to print it out in the star form.
And this is a good discussion topping on readability of your code.
Now, this is a simple example, but we can make this code a little bit cleaner.
For example, we can break things down so that we'll have password.
Will be lenth.
Password, so we're calculating the length.
So this is going to store six or whatever the input of our password is and it's nice and descriptive,
it's easy for other developers to understand.
And then in here.
I can also have hidden password and this hidden password will be the password lenth, and we're going
to use that star.
String and multiply it by the password length.
Let's make this a little bit bigger.
So that now our code can be understood well in an easier fashion, so we have the password lenth, so
we're going to say username your password password, but we want to make sure that it's the hidden password.
So we'll copy this over here.
So username your password, we're going to print out a hidden password is and then we're going to copy
password lenth.
Now, I argue that this reads better.
Because each line is doing something simple and then finally we're printing the output, and although
this is a small, simple example, this idea of readability and making and writing code that makes sense
is an important concept.
So let's see if this works.
I'm going to click run my username, Andre.
This time around, my password is going to be super secret.
And look at that.
Andre, your password did.
It is 11 letters long.
Good job getting this far.
Hopefully you got that.
I'll see you in the next video.