Created
January 11, 2024 01:53
-
-
Save ahsanzizan/fd356051c910a55ed352d93368511466 to your computer and use it in GitHub Desktop.
A handy random string generator
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(length): | |
# Define the characters to choose from | |
characters = string.ascii_letters + string.digits + string.punctuation | |
# Generate a random string of the specified length | |
random_string = ''.join(random.choice(characters) for _ in range(length)) | |
return random_string | |
length = int(input("Length: ")) | |
print(generate_random_string(length)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment