Skip to content

Random Password Generator #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
54 changes: 54 additions & 0 deletions Python/Random-password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import string
import random


alphabets = list(string.ascii_letters)
digits = list(string.digits)
special_characters = list("!@#$%^&*()")
characters = list(string.ascii_letters + string.digits + "!@#$%^&*()")

def generate_random_password():
length = int(input("Enter The Length Of Password: "))

alphabets_count = int(input("How Many Alphabets You Want : "))
digits_count = int(input("How Many Digits You Want : "))
special_characters_count = int(input("How Many Special Character You Want: "))

characters_count = alphabets_count + digits_count + special_characters_count


if characters_count > length:
print("Characters total count is greater than the password length")
return


password = []

for i in range(alphabets_count):
password.append(random.choice(alphabets))


for i in range(digits_count):
password.append(random.choice(digits))


for i in range(special_characters_count):
password.append(random.choice(special_characters))



if characters_count < length:
random.shuffle(characters)
for i in range(length - characters_count):
password.append(random.choice(characters))



random.shuffle(password)


print("".join(password))



generate_random_password()