Skip to content
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
17 changes: 17 additions & 0 deletions Password-Generator/mainpass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import random
import string

def generate_password(length):
"""Generate a random strong password."""
characters = string.ascii_letters + string.digits + string.punctuation
return ''.join(random.choice(characters) for _ in range(length))

if __name__ == "__main__":
try:
length = int(input("Enter password length: "))
if length <= 0:
print("Password length must be greater than 0.")
else:
print("Generated Password:", generate_password(length))
except ValueError:
print("Please enter a valid number.")
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Python-Projects
Beginner Level Python Projects, good first issue

Improve password generator with validation and function