Created
February 28, 2023 01:39
-
-
Save qlawmarq/9644135c346dce4e7a9705f28f07f39f to your computer and use it in GitHub Desktop.
Generate Random Strings and Passwords 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 random | |
import string | |
def generate_random_string(): | |
selects = random.sample(string.ascii_uppercase, 3) + random.sample( | |
string.digits, 3) + random.sample(string.ascii_lowercase, 3) | |
random.shuffle(selects) | |
unique_code = ''.join(selects) | |
print(unique_code) | |
return unique_code | |
generate_random_string() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment