This tutorial will show you how to program a password generator with the Python coding language.
The first thing that needs to be done is to import the libraries that will be used for the generator.
import string
from random import *
Next, is the main function of the generator.
## Creating List of characters, digits and symbols
data = string.ascii_letters + string.digits + string.punctuation
## Randomly selecting 8 to 16 characters from the List
password = "".join(choice(data) for x in range(randint(8,16)))
That’s it! Now all that has to be done is to print out the secure password. Here it the code in total.
import string
from random import *
## Creating List of characters, digits and symbols
data = string.ascii_letters + string.digits + string.punctuation
## Randomly selecting 8 to 16 characters from the List
password = "".join(choice(data) for x in range(randint(8,16)))
print (password)
If you run the code above you should get a password that looks like this
Output :
Njc(VceJ>7U