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') #Asks for parameters
- permissionRandomGenerator = input().lower()
- if permissionRandomGenerator == 'yes': #Initiates password generator
- print('How long do you want your password?')
- lengthRandomGenerator = int(input())
- def randInt():
- return math.floor(random.random()*10)
- def randChar():
- return alpha[math.floor(random.random()*27) - 1]
- randPasswordList = []
- listInsert = 0
- def changeCase(f):
- g = round(random.random())
- if g == 0:
- return f.lower()
- elif g == 1:
- return f.upper()
- while listInsert < lengthRandomGenerator + 1:
- randPasswordList.insert(listInsert, randInt())
- listInsert = listInsert + 1
- if listInsert >= lengthRandomGenerator + 1:
- break
- randPasswordList.insert(listInsert, randChar())
- randPasswordList[listInsert] = changeCase(randPasswordList[listInsert])
- listInsert = listInsert + 1
- continue
- listInsert = 0
- printList = 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 printList < (len(randPasswordList)-1):
- printItem = randPasswordList[printList]
- print(printItem)
- printList = printList + 1
- printList = 0
- randPasswordList = []
- elif permissionRandomGenerator == 'no':
- print('Too bad...')
- else:
- print('You had to answer Yes or No')
Add Comment
Please, Sign In to add comment