length = int(input('\nEnter the length of password: ')) Next, let’s ask the user for the length of the password. lower = string.ascii_lowercase upper = string.ascii_uppercase num = string.digits symbols = string.punctuation We will make use of string module for the same. We have stored lowercase and uppercase letters along with numbers and symbols. Let’s combine the data and store the data. temp = random.sample(all,length) password = "".join(temp) Now that we have the data, let’s make use of random module to finally generate the password. We are passing in the combined data along with the length of the password, and joining them at the end. all = string.ascii_letters string.digits string.punctuation pass = "".join(random.sample(all,length))įinally, let’s print the password! print(password) Now that you have a clear understanding of the script, we can even reduce the number of lines of code by eliminating the storage of data. Let’s have look at few sample outputs: #SAMPLE O/P: (length = 16) 3Atza*qP#h-vJoK 7c?gOt#M[}qr2 these steps, we have successfully created a random password generator project using python. Simple, isn’t it? Hope this tutorial has helped. I would strongly recommend you to Check out the YouTube video of the same and don’t forget to subscribe to my Channel. You can play around with the Instaloader library and even explore more features.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |