Last active
January 13, 2023 14:56
-
-
Save renatocfrancisco/02f6fa0d670d44a6276711a117719ab4 to your computer and use it in GitHub Desktop.
Random Password Generator in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
import random | |
def main(): | |
password_length = int(input("Length (int) of password? ")) | |
punctuation_option = input("Punctuation on password? (y/n)") | |
if(punctuation_option == 'y'): | |
characters = list(string.ascii_letters + string.digits + string.punctuation) | |
else: | |
characters = list(string.ascii_letters + string.digits) | |
random.shuffle(characters) | |
generate(password_length, characters) | |
def generate(password_length, characters): | |
password = [] | |
for x in range(password_length): | |
password.append(random.choice(characters)) | |
random.shuffle(password) | |
print("".join(password)) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment