You can download this code by clicking the button below.
This code is now available for download.
Generates a random string of specified length containing uppercase and lowercase letters and numbers.
Technology Stack : random, string
Code Type : Function
Code Difficulty : Intermediate
def random_string(length, allowed_chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"):
import random
import string
return ''.join(random.choice(allowed_chars) for _ in range(length))