You can download this code by clicking the button below.
This code is now available for download.
Generate a random string of a specified length and character set.
Technology Stack : random
Code Type : Function
Code Difficulty : Intermediate
def random_string(length, characters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"):
import random
return ''.join(random.choice(characters) for i in range(length))