how to make random password generator in python code example
Example 1: password generator python
import string
from random import *
characters = string.ascii_letters + string.punctuation + string.digits
password = "".join(choice(characters) for x in range(randint(8, 16)))
print password
Example 2: python password generator
import random
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@£$%^&*().,?0123456789'
number = input('Please enter a number of passwords.')
try:
number = int(number)
except:
print("Error, please enter a number!")
length = input('Length of password?')
try:
length = int(length)
except:
print("Error, please enter a number!")
print('\nHere are your password(s):')
for pwd in range(number):
password = ''
for c in range(length):
password += random.choice(chars)
print(password)
Example 3: password generator python
import random
i=0
list=[]
while i < 12:
while i < 8:
list.append(random.choice(string.ascii_letters))
i+=1
while i < 12:
list.append(random.randint(0, 9))
i+=1
list=' '.join([str(elem) for elem in list])
print("Your new password: ", list.replace(" ", ""))