Code Library
Random Password
Generater :
Program to genarate a Random password taking username and a random character and pantuation
import random
import string
def generate_password(name, extra, length, characters):
password = name + extra + ''.join(random.choice(characters) for _ in range(length))
return password
name = input("Enter your name: ")
extra = input("Enter something extra: ")
password_length = int(input("Enter the length of extra character: "))
print("Choose the types of characters needed:")
print("1. Lowercase letters")
print("2. Uppercase letters")
print("3. Digits")
print("4. Punctuation")
character_choices = input("Enter the numbers corresponding to the desired character types, separatedby commas: ")
character_types = ""
if "1" in character_choices:
character_types += string.ascii_lowercase
if "2" in character_choices:
character_types += string.ascii_uppercase
if "3" in character_choices:
character_types += string.digits
if "4" in character_choices:
character_types += string.punctuation
random_password = generate_password(name, extra, password_length, character_types)
print("Random Password:", random_password)
Enter your name: sam
Enter something extra: 789
Enter the length of extra character: 3
Choose the types of characters needed:
1. Lowercase letters
2. Uppercase letters
3. Digits
4. Punctuation
Enter the numbers corresponding to the
desiredcharacter types,
separatedby commas: 2,3,4
Random Password: sam789@1.