Skip to content

Instantly share code, notes, and snippets.

@Nishan8583
Created July 24, 2016 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nishan8583/2ef9842d5c437e19c27a182d13c8fe26 to your computer and use it in GitHub Desktop.
Save Nishan8583/2ef9842d5c437e19c27a182d13c8fe26 to your computer and use it in GitHub Desktop.
import random
def password_generator():
alpha = '''A- B1CDE2*FGH6IJ3&KL_M4NOP5QRS7TU^8VW9XY0Zabc@defg#hijk~lm%no!pqrs¬tuv`w|xy.$,z''' # these are the words and symbols from which the password is generaterd
ans = input('How Strong do you want your password to be : (strong/medium/low) ')
password = ''
while ans.lower() != 'q':
if ans == 'strong':
for i in range(0,12):
n = random.randint(0,69)
password = password + alpha[n]
print(password)
password = ''
elif ans == 'medium':
for i in range(0,8):
n = random.randint(0,69)
password = password + alpha[n]
print(password)
password = ''
elif ans == 'weak':
print('Warning, Weak password chosen'.center(180,'*')) # .center() is used just for decorations purpose, no need to stress about it
for i in range(0,5):
n = random.randint(0,69)
password = password + alpha[n]
print(password)
password = ''
else:
ans = input('Enter a valid option (strong/medium/weak)')
continue
ans = input('\n\nWant to generate another password (strong/medium/low) OR press Q/q to quit: ')
password_generator()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment