Python Random Password Generator:
We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it. |
We need to import the random library to create a random password generator in Python. First, we create a variable in which we pass lowercase letters, uppercase letters, numbers, and symbols. After that, we specify the password length and count of passwords under the while True loop. Now, we create logic in for loop as shown below.
Code:
Output:
Source Code for Python Password Generator: Do proper Code Indentation otherwise, the Source Code does not work and gives an error.
import random
characters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*_"
while True:
password_length = int(input("Enter the Length of required Password:--"))
password_count = int(input("Enter the Number of required Password:--"))
for x in range(0, password_count):
password = ""
for y in range(0, password_length):
password_char = random.choice(characters)
password = password + password_char
print("The generated password is", password)
repeat = input("Do you want to Generate More Passwords?")
if repeat == "no" or repeat == "No" or repeat == "NO":
break
print ("Thank You!")
Comments (No)