Created
August 17, 2021 04:25
-
-
Save thevickypedia/368e30f0f2b5df348480f6241a5c8a83 to your computer and use it in GitHub Desktop.
Generate alpha numeric phrase for a defined length
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
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