Advertisement
IsenfireLDC

Random Password Generator 1: Edits 1 <Faulty>

May 3rd, 2016
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 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 a():
  10.         return math.floor(random.random()*10)
  11.     def b():
  12.         return alpha[math.floor(random.random()*27)]
  13.     c = []
  14.     d = 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 d < lengthRandomGenerator:
  22.         c.insert(d, a())
  23.         d = d + 1
  24.         if d >= lengthRandomGenerator:
  25.             break
  26.         c.insert(d, b())
  27.         c[d] = changeCase(c[d])
  28.         d = d + 1
  29.         continue
  30.     d = 0
  31.     if lengthRandomGenerator <= 0:
  32.         print('It has to be longer than that')
  33.     elif lengthRandomGenerator >= 25:
  34.         print('I can\'t generate a password that long')
  35.     elif math.isnan(lengthRandomGenerator):
  36.         print('error: not valid data type')
  37.     else:
  38.         while d < (len(c)-1):
  39.             e = c[d]
  40.             print(e)
  41.             d = d + 1
  42.     d = 0
  43.     c = []
  44. elif permissionRandomGenerator == 'no':
  45.     print('Too bad...')
  46. else:
  47.     print('You had to answer Yes or No')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement