Advertisement
jhoward48

Untitled

Dec 11th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. #Challenge 3
  2. #Can you make a function which generates a random password of any length? #
  3. #the function should accept one parameter, the desired password length, and return a password.#
  4. #You may find it useful to import the choice function from the random module.
  5.  
  6. import random
  7. length=int(input(" how long do you want the pasword to be?"))
  8.  
  9. def password_generator(length):
  10.      letters ='abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTU'
  11.    
  12.      
  13.      
  14.      password =""
  15.      for i in range (length):
  16.           password =random.choice(letters)
  17.           print (password, end ='')
  18.      
  19.      
  20. password_generator(length)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement