You can download this code by clicking the button below.
This code is now available for download.
This function generates a random string of a specified length using the 'random' built-in module.
Technology Stack : random
Code Type : String generation
Code Difficulty :
import random
def generate_random_string(length):
"""
Generate a random string of given length using the 'random' module.
"""
letters = 'abcdefghijklmnopqrstuvwxyz'
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str