• 🌙 Community Spirit

    Ramadan Mubarak! To honor this month, Crax has paused NSFW categories. Wishing you peace and growth!

program to generate random password and the minimum length is a digit (1 Viewer)

Currently reading:
 program to generate random password and the minimum length is a digit (1 Viewer)

Recently searched:

yohilax951

Member
LV
1
Joined
Dec 20, 2023
Threads
62
Likes
32
Awards
5
Credits
3,814©
Cash
0$
import random
import string

def generate_password(min_length):
if min_length < 1:
print("Minimum length should be at least 1.")
return

# Ensure at least one digit
password = [random.choice(string.digits)]

# Add random characters to meet the minimum length
password += [random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(min_length - 1)]

# Shuffle the password to randomize the order
random.shuffle(password)

return ''.join(password)

# Example: Generate a password with a minimum length of 8 characters
min_length = 8
random_password = generate_password(min_length)
print("Random Password:", random_password)
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Tips
Recently searched:

Similar threads

Users who are viewing this thread

Top Bottom