Check If A Password Is Valid | Python Example
Вставка
- Опубліковано 27 сер 2024
- How to check the validity of password in Python to see if it meets the password requirements (e.g. a minimum number of characters, at least one upper case letter, and so on). Source code: github.com/por.... Check out www.portfolioc... to build a portfolio that will impress employers!
How would one go about having it check for multiple passwords after every keystroke without requiring you to press Enter? Ex. AAAA is the password and I can press keys 100 times and it will keep checking on its own until it sees AAAA as the last four characters pressed. Was toying with a little coded lock box I made and children like to just randomly press buttons so i want it so people can just randomly press buttons and it unlocks if they happen to press the right sequence.
can we use recursive version ? like we increment character by character from the pass and check with if statments
Yes it's possible to make a recursive version. With C we can do it in a very nice way by passing a pointer to the next character in the string to the next recursive call of the function, and stopping once we reach the null terminator. With Python strings are immutable objects, which means we can't change them, only create new strings. And when we access a 'character' in a string we are really accessing a substring of one character. So we may do things a bit differently for a recursive solution.. maybe one of the function arguments is the index of the character we are accessing, we increment it each time the function is called, and we stop the function calls when the index reaches the length of the string. :-)