samedi 4 avril 2015

python script to accept 8 char password with these conditions only: 2 num, 2 upper, 2 lower, and 2 special

This is what I've done till now. And when it goes wrong it doesn't print 'Not Okay'. I'm still not able to figure out how to check special chars.



#!/usr/bin/python

def passw_check():
passin = raw_input("Enter the password")

if len(passin) == 8: # checking total length of password
if sum(map(str.isupper, passin))== 2: #check 2 upper chars
if sum(map(str.islower, passin))== 2: #check 2 lower chars
if sum(map(str.isdigit, passin))== 4: #check 2 digits chars
print 'Passwords Okay'
else:
print 'Not Okay!'

passw_check()

Aucun commentaire:

Enregistrer un commentaire