Create a simple password generator in Python

Python password generator exercise lab

In this practice lab, we will learn how to create a simple password generator in Python 3.


TASK

Create a simple password generator in Python3 which asks you to input the number of passwords & number of characters in each password. Password-set should contain:

  • Digits (0-9)
  • Small alphanumeric letters (a-z)
  • Capital alphanumeric letters (A-Z)
  • Special characters (!@#$%^&*)

SOLUTION


#Simple password generator to generate passwords with desired characters length each (www.networkwalks.com)



import random
characterset = '0123456789' + 'abcdefghijklmnopqrstuvwxyz' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + '!@#$%^&*'
no_of_passwords = input("Please enter how many passwords do you want: ")
length = input("Please enter length of each password: ")

for j in range(0,int(no_of_passwords)):
    pass1 = ""
    for i in range(0,int(length)):
     pass1 = pass1 + pass1.join((random.choice(characterset)))
    print(pass1)
 
www.networkwalks.com


You might also be interested in our free Online Quizzes on all IT topics including Cisco CCNA, Cyber Security, Python Programming, Linux & Ethical Hacking:

You can also view free study notes (Cheat sheets) for long term memory:

Follow our Facebook Page & YouTube Channel for more updated Cheatsheets & Quizzes after doing this Transport & Application Layers Quiz:

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments