Template request | Bug report | Generate Data Product
Tags: #python #password #random #snippet #operations
Author: Sunny
Description: The objective of this notebook is to Create Strong random password.
Import the necessary libraries: random,string
import random
import string
word_length = 18
special_char = "!@#$%&"
# Generate a list of letters, digits, and some punctuation
components = [string.ascii_letters, string.digits, special_char]
# flatten the components into a list of characters
chars = []
for clist in components:
for item in clist:
chars.append(item)
# Store the generated password
password = []
# Choose a random item from 'chars' and add it to 'password'
for i in range(word_length):
rchar = random.choice(chars)
password.append(rchar)
# Return the composed password as a string
generated_password = "".join(password)
print(f"Password Successfully generated: {generated_password}!")