You can download this code by clicking the button below.
This code is now available for download.
Generate a random string of a specified length.
Technology Stack : random, string operations
Code Type : Function
Code Difficulty : Intermediate
import random
def generate_random_string(length=10):
"""
Generate a random string of specified length.
"""
letters = 'abcdefghijklmnopqrstuvwxyz'
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str