You can download this code by clicking the button below.
This code is now available for download.
This function generates a random password of a specified length consisting of letters and digits.
Technology Stack : math, random, string
Code Type : Function
Code Difficulty : Intermediate
import math
import random
import string
import time
def generate_random_password(length=12):
if not isinstance(length, int) or length <= 0:
raise ValueError("Length must be a positive integer")
characters = string.ascii_letters + string.digits
password = ''.join(random.choice(characters) for i in range(length))
return password