Given a password, we have to categorize it as a strong or weak one. There are some checks that need to be met to be a strong password. For a weak password, we need to return the reason for it to be weak.
Conditions to be fulfilled are:
- Minimum 9 characters and maximum 20 characters.
- Cannot be a newline or a space
- There should not be three or more repeating characters in a row.
- The same string pattern(minimum of two character length) should not be repeating.
Note: For checking the basic validations of a password, click here.
Input1 : Qggf!@ghf3 Output1 : Strong Password! Input2 : aaabnil1gu Output2 : Weak Password: Same character repeats three or more times in a row Input3 : Geeksforgeeks Output3 : Weak Password: Same character repeats three or more times in a row Input4 : Aasd!feasnm Output4 : Weak password: Same string pattern repetition Input5 : 772*hdf77 Output5 : Weak password: Same string pattern repetition Input6 : " " Output6 : Password cannot be a newline or space!
Below is the implementation.
Weak password: Same string pattern repetition
Weak Password: Same character repeats three or more times in a row
Password cannot be a newline or space!
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course