You can download this code by clicking the button below.
This code is now available for download.
Generates a random string of a specified length containing uppercase and lowercase letters and numbers.
Technology Stack : random
Code Type : String generation
Code Difficulty : Beginner
import random
def generate_random_string(length=10):
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str