Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import random
- alpha = ['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']
- print('Would you like a random password suggestion generator', 'Yes or No')
- permissionRandomGenerator = input().lower()
- print('How long do you want your password?')
- lengthRandomGenerator = int(input())
- if permissionRandomGenerator == 'yes':
- def a():
- return math.floor(random.random()*10)
- def b():
- return alpha[math.floor(random.random()*27)]
- c = []
- d = 0
- def changeCase(f):
- g = round(random.random())
- if g == 0:
- return f.lower()
- elif g == 1:
- return f.upper()
- while d < lengthRandomGenerator:
- c.insert(d, a())
- d = d + 1
- if d >= lengthRandomGenerator:
- break
- c.insert(d, b())
- c[d] = changeCase(c[d])
- d = d + 1
- continue
- d = 0
- if lengthRandomGenerator <= 0:
- print('It has to be longer than that')
- elif lengthRandomGenerator >= 25:
- print('I can\'t generate a password that long')
- elif math.isnan(lengthRandomGenerator):
- print('error: not valid data type')
- else:
- while d < (len(c)-1):
- e = c[d]
- print(e)
- d = d + 1
- d = 0
- c = []
- elif permissionRandomGenerator == 'no':
- print('Too bad...')
- else:
- print('You had to answer Yes or No')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement