diff --git a/password_generator/README.md b/password_generator/README.md new file mode 100644 index 0000000..f268c4b --- /dev/null +++ b/password_generator/README.md @@ -0,0 +1,8 @@ +# Password Generator + +A simple Python program that generates a random password based on user-defined length. + +## Features +- Generates strong passwords +- Includes letters, numbers, and symbols +- Input validation included \ No newline at end of file diff --git a/password_generator/main.py b/password_generator/main.py new file mode 100644 index 0000000..e3eec6f --- /dev/null +++ b/password_generator/main.py @@ -0,0 +1,20 @@ +import random + +characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_+=" + +try: + length = int(input("Enter password length: ")) + + if length <= 0: + print("Please enter a positive number.") + else: + password = "" + + for i in range(length): + char = random.choice(characters) + password += char + + print("Generated Password:", password) + +except ValueError: + print("Invalid input! Please enter a number.") \ No newline at end of file