-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task1.py
58 lines (40 loc) · 1.2 KB
/
Task1.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## Project On Random Password Generator in Python
## Imported Library ##
import string
import random
# Typing the password length you want
length = int(input("Enter The password length You Wish For: "))
print('''Choose the character set for password from these :
1. Digits
2. Letters
3. Special characters
4. Exit''')
character_List = ""
# Getting the character set for password
### Conditional loop
while(True):
choice = int(input("Pick a number "))
if(choice == 1):
# Adding the letters to possible characters
character_List += string.ascii_letters
elif(choice == 2):
# Adding the digits to possible characters
character_List += string.digits
elif(choice == 3):
# Adding the special characters to possible
# characters
character_List += string.punctuation
elif(choice == 4):
break
else:
print("Please pick a valid option!")
password = []
for i in range(length):
# Picking a random character from our
# character list
randomchar = random.choice(character_List)
# appending a random character to password
password.append(randomchar)
# printing password as a string
print("The random password is " + "".join(password))
### The Code is ended, Thank You CodeClause ####