Skip to content

Instantly share code, notes, and snippets.

@qlawmarq
Created February 28, 2023 01:39
Show Gist options
  • Save qlawmarq/9644135c346dce4e7a9705f28f07f39f to your computer and use it in GitHub Desktop.
Save qlawmarq/9644135c346dce4e7a9705f28f07f39f to your computer and use it in GitHub Desktop.
Generate Random Strings and Passwords in Python
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