Python Programming/Password checker

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The basic premise of a password checker is to check passwords...

sounds simple enough, right? Just basic string analysis. But recently I have been issued a challenge to make sure the string doesn't contain any consecutive letters on a qwerty keyboard (see bottom of page). I have just completed the basic premise and come up with this code:

    password = input('password:')
    rows = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'] 
    for r in range rows:
        for i in range(len(password)):
            for j in range(len(r)):
                if rows[j:j+2] == password[i:i+2]:
                    print('NO' + password[i:i+2]) # Here you need to change it to an appropriate error message

Hope this helps everyone else on a now advanced password checker!


just FYI, qwerty keyboards are:

q w e r t y u i o p
 a s d f g h j k l 
   z x c v b n m