You can download this code by clicking the button below.
This code is now available for download.
Generates a random password of a specified length, composed of uppercase and lowercase letters and digits.
Technology Stack : os, sys, time, json, re, random, string, math
Code Type : Function
Code Difficulty : Intermediate
import os
import sys
import time
import json
import re
import random
import string
import math
def generate_random_password(length):
if not isinstance(length, int) or length <= 0:
raise ValueError("Password length must be a positive integer")
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))