Random String Generator

  • Share this:

Code introduction


This function generates a random string of a specified length, consisting of both uppercase and lowercase letters.


Technology Stack : os, re, random, string, sys

Code Type : Function

Code Difficulty :


                
                    
import os
import re
import random
import string
import sys

def generate_random_string(length):
    letters = string.ascii_letters
    return ''.join(random.choice(letters) for i in range(length))