python password generator scrip code example
Example 1: 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 2: 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(" ", ""))