1import string
2from random import *
3characters = string.ascii_letters + string.punctuation + string.digits
4password = "".join(choice(characters) for x in range(randint(8, 16)))
5print password
6
1import random
2chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@£$%^&*().,?0123456789'
3
4number = input('Please enter a number of passwords.')
5try:
6 number = int(number)
7except:
8 print("Error, please enter a number!")
9
10length = input('Length of password?')
11try:
12 length = int(length)
13except:
14 print("Error, please enter a number!")
15
16print('\nHere are your password(s):')
17
18for pwd in range(number):
19 password = ''
20 for c in range(length):
21 password += random.choice(chars)
22 print(password)
1import random
2
3alph = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ\
4 abcdefghijklmnopqrstuvwxyz\
5 1234567890 !@#$%^&*(){}[]<>,.')
6out = ''
7for char in string:
8 out += random.choice(alph)
9
10print(out)
1#This is giving you a password with 8 strings and 4 numbers:
2import random
3i=0
4list=[]
5while i < 12:
6 while i < 8:
7 list.append(random.choice(string.ascii_letters))
8 i+=1
9 while i < 12:
10 list.append(random.randint(0, 9))
11 i+=1
12
13list=' '.join([str(elem) for elem in list])
14print("Your new password: ", list.replace(" ", ""))
1import random
2import string
3
4x = str(input("Do you want a password? y/n "))
5
6list = []
7if x == "y":
8 print("Alright!")
9 for i in range(16):
10 _1 = random.choice(string.ascii_letters)
11 _2 = random.randint(1, 9)
12 list.append(_1)
13 list.append(_2)
14else:
15 print("ok")
16
17
18def convert(list):
19
20 s = [str(i) for i in list]
21
22 res = "".join(s)
23
24 return(print(res))
25
26
27
28convert(list)
29
30
1import random
2letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
3numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
4symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
5print("Welcome to the PyPassword Generator!")
6nr_letters = int(input("How many letters would you like in your password?\n"))
7nr_symbols = int(input(f"How many symbols would you like?\n"))
8nr_numbers = int(input(f"How many numbers would you like?\n"))
9password_list = []
10for char in range(1, nr_letters + 1):
11 password_list.append(random.choice(letters))
12for char in range(1, nr_symbols + 1):
13 password_list += random.choice(symbols)
14for char in range(1, nr_numbers + 1):
15 password_list += random.choice(numbers)
16
17random.shuffle(password_list)
18password = ""
19for char in password_list:
20 password += char
21print(f"Your password is: {password}")