Random Password Generator Beginner Python Project!

LeMaster Tech
183 followers
10 Video Views·Apr 22, 2025
This video utilizes the random module in Python to create a password generator that takes user input to ask for total password length, then randomly select between uppercase letters, lowercase letters, numerical, special characters and spaces! We then output the end solution and give the user a secret password that has been randomly generated!
Thanks for watching, be sure to like and subscribe, and let us know what you'd like to see in a future video in the comments below!
Thanks!
what's going on you guys welcome back to
the channel and today's video will be
showing how to create a random generator
password creator in python
[Music]
okay so first things first if you want
this
uh password to be randomly generated
then you're going to want to import the
random module if you don't have it
installed yet run pip to install it and
the second thing you're going to want to
do is create a bunch of lists of the
characters that you want to go into your
password as you'll see in a little bit i
think the easiest way to do this
i think the easiest way to do this is to
separate out numbers lowercase uppercase
and special characters and you don't
want to see me type out the whole
alphabet twice so i am going to copy in
my
lists just to show you you may want to
type out a list of all the lowercase all
the uppercase
i like having a space as its own list
because i like the probability of a
space being approximately one in five
just because spaces are one of the
hardest characters to crack in most
password crackers because they don't
include a space considering like
multiple words okay so
then actually what you're going to want
to do is put all of your other lists
into a master list so if we put numbers
lowers
uppers space
and characters into a list you'll see
how we're going to use this to
essentially like cycle through the
different options and randomly select
which one's going to happen
so create your password variable and
it's going to be empty initially
and what we're going to do is we're
going to say for i
in range
and we're going to be creating a
variable called length so
eventually i want length to be something
we get as an input but for now i'll just
make length 10 just for writing the code
okay and for iron range length the pick
is going to be
and here's where we start using random
it's going to be random dot
random integer
0 to 4 right because we have
0 1 2 3 4. so somewhere in this range
it's going to choose from
the the choices so then we're going to
go down and say this specific choice
is coming out of choices and it's going
to be that pick variable that we just
made and then it's going to be at
position
random dot
rand int
and then this one is going to go from
zero to the length of whatever we just
picked
minus one because this is end inclusive
okay and we don't want it out of range
and so to maybe make this a little bit
easier to read
i actually gotta separate that out there
to make this a little bit easier to read
um i could do this second piece which
would be
selector i guess we could call it that
selector
and just to talk quickly about what
we're doing here
choices is now a list of lists and so
what we need are two index values we
need this first pick zero to four to say
which list we're going to check but then
the second one we can't do a firm range
like that because we don't know and
actually this is just the same as saying
length of choices
just
length of choices
minus one it's the same as doing that we
just happen to know it's four so it's a
little bit easier to write but um so
this way we're actually selecting a
specific choice and then all we're going
to do because we they're already all
strings so we don't have to worry about
adding like an str formatter to it
we're just going to add whatever that
choice was to the previous password and
then we're going to
print
print the password okay so if i run this
now it should give us 10 characters
here you go
10 characters it looks like we got two
spaces in a row that would actually be a
super secure password
but then if you want make this a little
more descriptive you can say
your secret password is
and then just print out the password
and what i like like i said i want to be
varying in length based on user input so
we're going to do int input and then
how long do you want the password to be
and then we'll ask him just with a
question mark and we'll integer convert
it and then we'll make it a length so if
i run it now how long do you want the
password to be let's make it 20.
okay so starting here
i can copy this 20 character long secret
password and i can run this infinite
numbers of times so this really has like
a lot of different uses you could create
an encoder
based on this sort of uh thing so that's
how you create a password lookup i hope
you like this simple python project i
have tons of python pygame and other
software
tutorials on the channel so be sure to
check the channel out if you did like it
please leave a like on the video
subscribe to the channel helps me out a
ton and let me know what you'd like to
see in a future video thanks for
watching and good luck with your code
thanks bye
