Created
June 29, 2021 15:57
-
-
Save manoj-015/28b7b0cddb35088ca0c0cfafd8b6439a to your computer and use it in GitHub Desktop.
Python Program to generate Random passoword using Random Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Random Password Generator Project | |
#imported random module | |
import random | |
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] | |
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] | |
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+'] | |
print("Welcome to the Random Password Generator!") | |
nr_letters = int(input("How many letters would you like in your password?\n")) | |
nr_symbols = int(input("How many symbols would you like?\n")) | |
nr_numbers = int(input("How many numbers would you like?\n")) | |
#created a empty list | |
password_list = [] | |
for i in range(nr_letters): | |
password_list.append(random.choice(letters)) | |
for i in range(nr_symbols): | |
password_list += random.choice(symbols) | |
for i in range(nr_numbers): | |
password_list += random.choice(numbers) | |
# rand_num = random.randint(0 , nr_numbers - 1) | |
# password_list += numbers[rand_num] | |
random.shuffle(password_list) | |
print("Your Random Password is :") | |
for char in password_list: | |
print(char,end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment