generate a password of 8 characters that contains at least one uppercase letter, one lowercase letter, and one number in python

main.py
import random
import string

def generate_password():
    password = []
    # Generate at least one uppercase letter
    password.append(random.choice(string.ascii_uppercase))
    # Generate at least one lowercase letter
    password.append(random.choice(string.ascii_lowercase))
    # Generate at least one number
    password.append(random.choice(string.digits))
    # Generate remaining characters
    for _ in range(5):
        password.append(random.choice(string.ascii_letters + string.digits))
    # Shuffle the characters
    random.shuffle(password)
    # Convert the list to a string and return
    return ''.join(password)

# Example usage
print(generate_password())  # Output: vP5oM3Fq
698 chars
22 lines

gistlibby LogSnag