Random password generator with python
Mar 25, 2021
This is how to create a very simple python program to generate a random password.
Check out the code below
import randomcharacters = 'abcdefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVXYZ!@#$&1234567890'char_len = len(characters)k = int(input("How many characters do you need? : "));password = ''def gen_pswd(): global k, password while (k > 0): password = password + (characters[random.randint(0,char_len)]) k = k-1 return (password)print("Suggested password is",gen_pswd())
In order to get a random integer to application, should import ‘random’ module to app.
More characters can be added to ‘characters’ string.
randint(a,b) returns a random integer within a given range.