passgen.py 414 B

12345678910111213141516
  1. from random import choice
  2. def pass_gen(length):
  3. chars = "#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  4. passwd = ""
  5. for i in range(length):
  6. passwd = passwd + choice(chars)
  7. return passwd
  8. def main():
  9. length = int(input("Enter password length: "))
  10. print("password: ",pass_gen(length=length))
  11. if __name__ == "__main__":
  12. main()