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 containing both uppercase and lowercase letters and numbers.
Technology Stack : math, os, random, string, datetime, heapq
Code Type : Function
Code Difficulty : Intermediate
import math
import os
import random
import string
import datetime
import heapq
def random_string(length=10):
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))