when press f5(python idle) blank screen when follow press 1 go generator e.c.t
#all imports used import random import time import re import sys import string def menu(): print("welcome password generator , checker") choice = int(input(""" 1) generate password 2) check password 3) quit """)) if choice == 1: gp(10) elif choice == 2: cf() elif choice == 3: print("goodbye") time.sleep(0.5) print("come next time") sys.exit() else: print("please select valid choice") def cf(): print("welcome password checker") #i think def underneath message maybe problem idk def gp(num): print("welcome password generator") time.sleep(0.5) print("this generator generates range of symbols,characters , numbers strongest , secure password") password = " " n in range(num): x = random.randint(0,94) password += string.printable[x] return password print (gp(12)) menu()
short solution
if generating 12-character password string need, use string
library , `random.choice:
import string import random def gp(num) return (''.join(random.choices(string.ascii_letters + string.digits, k=num))) print (gp(12))
alternative solution without string package:
if don't want introduce dependency on string package, generate own valid characters string this:
def gp(num): return (''.join(random.choices('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz*&[](){}1234567890',k=num))
Comments
Post a Comment