def generate_random_string(n): letters = string.ascii_letters + string.digits return ''.join(random.choice(letters) for _ in range(n))