Advertisement
IsenfireLDC

Random Password Generator 1: Edits 1 (renamed vars) <Faulty>

May 4th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.78 KB | None | 0 0
  1. import math
  2. import random
  3. 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']
  4. print('Would you like a random password suggestion generator', 'Yes or No')
  5. permissionRandomGenerator = input().lower()
  6. print('How long do you want your password?')
  7. lengthRandomGenerator = int(input())
  8. if permissionRandomGenerator == 'yes':
  9.     def randInt():
  10.         return math.floor(random.random()*10)
  11.     def randChar():
  12.         return alpha[math.floor(random.random()*27)]
  13.      randPasswordList = []
  14.     listInsert = 0
  15.     def changeCase(f):
  16.         g = round(random.random())
  17.         if g == 0:
  18.             return f.lower()
  19.         elif g == 1:
  20.             return f.upper()
  21.     while listInsert < lengthRandomGenerator:
  22.         randPasswordList.insert(listInsert, randInt())
  23.         listInsert = listInsert + 1
  24.         if listInsert >= lengthRandomGenerator:
  25.             break
  26.         randPasswordList.insert(listInsert, randChar())
  27.         randPasswordList[listInsert] = changeCase(randPasswordList[listInsert])
  28.         listInsert = listInsert + 1
  29.         continue
  30.     listInsert = 0
  31.     printList = 0
  32.     if lengthRandomGenerator <= 0:
  33.         print('It has to be longer than that')
  34.     elif lengthRandomGenerator >= 25:
  35.         print('I can\'t generate a password that long')
  36.     elif math.isnan(lengthRandomGenerator):
  37.         print('error: not valid data type')
  38.     else:
  39.         while printList < (len(randPasswordList)-1):
  40.             printItem = randPasswordList[printList]
  41.             print(printItem)
  42.             printList = printList + 1
  43.     printList = 0
  44.     randPasswordList = []
  45. elif permissionRandomGenerator == 'no':
  46.     print('Too bad...')
  47. else:
  48.     print('You had to answer Yes or No')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement