Skip to content

Instantly share code, notes, and snippets.

@thevickypedia
Created August 17, 2021 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thevickypedia/368e30f0f2b5df348480f6241a5c8a83 to your computer and use it in GitHub Desktop.
Save thevickypedia/368e30f0f2b5df348480f6241a5c8a83 to your computer and use it in GitHub Desktop.
Generate alpha numeric phrase for a defined length
from random import choices
from string import ascii_letters, digits
def alpha_numeric(length: int = 20) -> str:
"""Generates alpha numeric phrase.
Args:
length: Length of the phrase that should be generated.
Returns:
str:
Randomly generated alpha numeric phrase.
"""
return ''.join(choices(ascii_letters + digits, k=length))
if __name__ == '__main__':
print(alpha_numeric(length=49))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment