Random String Generator

  • Share this:

Code introduction


This function generates a random string of specified length, composed of uppercase and lowercase letters and numbers.


Technology Stack : Python built-in libraries

Code Type : Python Function

Code Difficulty : Intermediate


                
                    
import random
from robot.libraries.BuiltIn import BuiltIn

def generate_random_string(length):
    chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
    return ''.join(random.choice(chars) for _ in range(length))