Python Project – Random Password Generator

v2.0 – 11.09.2024

Random Password Generator Project#

#Random Password Generator Project# 
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 = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
kanji_list = [
    '日', '一', '国', '年', '大', '十', '二', '本', '中', '長',
    '出', '三', '時', '行', '見', '月', '後', '前', '生', '五',
    '間', '上', '東', '四', '今', '金', '九', '入', '学', '高',
    '円', '子', '外', '八', '六', '下', '来', '気', '小', '七',
    '山', '話', '女', '北', '午', '百', '書', '先', '名', '川', '千']

print("Welcome to the PyPassword Generator!")
nr_letters = int(input("How many letters would you like in your password?\n"))
nr_numbers = int(input("How many numbers would you like in your password?\n"))
nr_symbols = int(input("How many symbols would you like in your password?\n"))
nr_kanji_characters = int(input("How many kanji characters would you like in your password?\n"))

password = []

for char in range(nr_letters):
   password += random.choice(letters)

for char in range(nr_symbols):
   password += random.choice(symbols)

for char in range(nr_numbers):
   password += random.choice(numbers)

for char in range(nr_kanji_characters):
   password += random.choice(kanji_list)

random.shuffle(password)

pw = ""

for char in password:
   pw += char

print(pw)

#############################################################

Code Explanation:
Initialize Variables:
password is a string that contains the characters you want to process.
pw is an empty string that will be used to accumulate the characters from password.
Iterate Over Each Character in password:
Use a for loop to go through each character in password.
For each character, append it to the pw string.
Print the Final pw String:
After the loop completes, print the accumulated pw string.

#############################################################


Posted

in

by