Advertisement
Wastebinonpastebin

random_password

Sep 22nd, 2020 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import random
  2.  
  3. password = "" #create text field
  4. i = 1 #i represents the positions in "password"
  5.  
  6. while (i <= 10): #password is limited to 10 characters
  7.  
  8.     rand = random.randint(0,127) #random number between 0-127 (ASCII)
  9.  
  10.     if (rand < 33 or rand > 122):
  11.  
  12.         pass #repeat loop without any changes
  13.  
  14.     else:
  15.         password = password + chr(rand) #insert random generatet character into "password"
  16.         i += 1 #go on to the next position in "password"
  17.  
  18. print(password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement