I had an assignment for school with a test to make a program that checks password strength. as you can see below i've made the program. When I turned it in, I received it back because it's to convenient to use the builtin function any()
. how can i adjust or change my program to not include the any()
function.
import time
print ("Check of uw wachtwoord veilig genoeg is in dit programma.")
time.sleep(1)
print ("Uw wachtwoord moet tussen minimaal 6 en maximaal 12 karakters
bestaan")
print ("U kunt gebruik maken van hoofdletters,getallen en symbolen (@,#,$,%)")
klein = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
groot = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
nummers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
symbolen= [' ', '!', '#', '$', '%', '&', '"', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~',"'"]
def ok(passwd,l):
return any(k in passwd for k in l) # checkt of een letter in de lijst in het wachtwoord zit.
while True:
inp = input("Wilt u dit programma gebruiken? ja/nee: ")
if inp == "nee" and "Nee" and "NEE":
break
elif inp == "ja" and "Ja" and "JA":
ww = input("Voer uw wachtwoord in: ")
if len(ww) < 6:
print ("uw wachtwoord is te kort, uw wachtwoord moet uit minimaal 6 en maximaal 12 karakters bestaan!")
elif len(ww) > 12:
print ("uw wachtwoord is te lang, uw wachtwoord moet uit minimaal 6 en maximaal 12 karakters bestaan!")
elif len(ww) >= 6 and len(ww)<= 12:
sww = set(ww) # set is een onorganiseerde verzameling dat betekent dat het niet op order is bijv. SaUj%2F3 = Oonorganiseerd
if all(ok(sww,l) for l in [klein,groot,nummers,symbolen]):
print ("uw wachtwoord is Zeer sterk")
elif all(ok(sww,l) for l in [klein,groot,nummers]):
print ("uw wachtwoord is Sterk")
elif all(ok(sww,l) for l in [klein,groot,symbolen]):
print ("uw wachtwoord is Sterk")
elif all(ok(sww,l) for l in [groot,nummers,symbolen]):
print ("uw wachtwoord is Sterk")
elif all(ok(sww,l) for l in [nummers,symbolen,klein]):
print ("uw wachtwoord is Sterk")
elif all(ok(sww,l) for l in [nummers,symbolen]):
print ("uw wachtwoord is Medium")
elif all(ok(sww,l) for l in [groot,nummers]):
print ("uw wachtwoord is Medium")
elif all(ok(sww,l) for l in [groot,symbolen]):
print ("uw wachtwoord is Medium")
elif all(ok(sww,l) for l in [klein,groot]):
print ("uw wachtwoord is Medium")
elif all(ok(sww,l) for l in [klein,nummers]):
print ("uw wachtwoord is Medium")
elif all(ok(sww,l) for l in [klein,symbolen]):
print ("uw wachtwoord is Medium")
elif all(ok(sww,l) for l in [klein]):
print ("uw wachtwoord is Zwak")
elif all(ok(sww,l) for l in [symbolen]):
print ("uw wachtwoord is Zwak")
elif all(ok(sww,l) for l in [nummers]):
print ("uw wachtwoord is Zwak")
elif all(ok(sww,l) for l in [groot]):
print ("uw wachtwoord is Zwak")