scipiguy

Programming 102: Random password generator

Jun 22nd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #Random password with specified number of characters
  2.  
  3. from random import randint
  4.  
  5. def password_generator(length):
  6.     new_password = []
  7.     for x in range(pass_length):
  8.         character = chr(randint(32,126))
  9.         #print(character)
  10.         new_password.append(character)
  11.     processed_password = (', '.join(new_password))
  12.     processed_password = processed_password.replace(', ', '')
  13.     print("Your randomly generated password is " + processed_password)
  14.        
  15. pass_length = int(input("How many characters do you want in the random password?"))
  16. password_generator(pass_length)
Advertisement
Add Comment
Please, Sign In to add comment