-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPassword-generator.py
37 lines (28 loc) · 950 Bytes
/
Password-generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import random
import pyperclip
print("Password generator")
Characters = "qwertyuiopasdfghjklzxcvbnm1234567890øæå,*^_:@£$€{[]}´<>.-|+§!§!#¤%&/()=?"
CharList = list(Characters)
CharList2 = list(CharList[0:36])
Answer = input("""Would you like to exclude special characters?
(answer "yes" if so) """)
while True:
PasswordChars = []
try:
Lenght = input("What will be the lenght of the password? ")
Lenght = int(Lenght)
except ValueError:
print("Please type in valid input")
continue
if Answer == "yes":
while Lenght > len(PasswordChars):
char = random.choice(CharList2)
PasswordChars.append(char)
else:
while Lenght > len(PasswordChars):
char = random.choice(CharList)
PasswordChars.append(char)
Password = str()
Password = "".join(PasswordChars)
pyperclip.copy(Password)
print(Password)