Mar-15-2023, 08:50 AM
Another way. generates a random 10 character password
import os from random import choices from string import digits, ascii_letters # Define a function to generate and return a 10 character password def generate(): characters = digits+ascii_letters+'@#$&!' return ''.join(choices(characters, k=10)) # Define a function to clear the terminal def clear(): return os.system('cls' if os.name == 'nt' else 'clear') # Start the loop while True: # Clear the terminal, generate a password and ask for password clear() mypassword = generate() password = input('What is the password?: ') # Check if password matches if password == mypassword: # Password matches do stuff print('Password matched') else: # Password does not match print('Password does not match') print(f'Password is {mypassword}') # Ask to go again ask is forced to lower case ask = input('Try again?: ').lower() # if ask is y or yes go again else exit if ask in ['yes', 'y']: continue else: clear() print('Goodbye!') break
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts