From 14a1ea9fdd3cc2a885da4081cc707484d9286a99 Mon Sep 17 00:00:00 2001 From: Blake Ridgway Date: Fri, 20 Dec 2024 08:17:19 -0600 Subject: [PATCH] Create main.py --- main.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..d81fdd1 --- /dev/null +++ b/main.py @@ -0,0 +1,29 @@ +import random +import string + +def generate_password(length=16): + characters = string.ascii_letters + string.digits + string.punctuation + password = ''.join(random.choice(characters) for _ in range(length)) + return password + +def main(): + print("Welcome to the Random Password Generator!") + while True: + try: + length = int(input("Enter the desired password length (default is 16): ") or 16) + if length <= 0: + print("Please enter a positive number.") + continue + password = generate_password(length) + print(f"Your generated password is: {password}") + except ValueError: + print("Invalid input. Please enter a number.") + continue + + again = input("Do you want to generate another password? (yes/no): ").strip().lower() + if again not in ['yes', 'y']: + print("Thank you for using the Random Password Generator.") + break + +if __name__ == "__main__": + main()