Skip to content

create strong_password_detection.py #10885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions strong_password_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
def strong_password_detection(password):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the filename to strings/strong_password_detection.py

AllowedSymbols = ["#", "@", "$", "_", "*", "-"]
Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We require type hints and doctests... Please add tests to cover all the cases below.

Suggested change
def strong_password_detection(password):
AllowedSymbols = ["#", "@", "$", "_", "*", "-"]
def strong_password_detection(password: str) -> bool:
"""
>>> strong_password_detection("str0ng@Password")
True
>>> strong_password_detection("str0ngPassword")
False
"""
allowed_symbols = {c for c in "#@$_*-"}

flag = 1
# length of the entered password should be at least 6
if len(password) < 6:
print("length of the entered password should be at least 6")
flag = 0
# length of the entered password should be not be greater than 15
if len(password) > 15:
print("length of the entered password should be not be greater than 15")
flag = 0
# The entered password should have at least one numeral
if not any(char.isdigit() for char in password):
print("The entered password should have at least one numeral")
flag = 0
# Password should have at least one lowercase letter
if not any(char.islower() for char in password):
print("the entered password should have at least one lowercase letter")
flag = 0
# The entered password should have at least one uppercase letter
if not any(char.isupper() for char in password):
print("The entered password should have at least one uppercase letter")
flag = 0
# The entered password should have at least one of the symbols $@#_*
if not any(char in AllowedSymbols for char in password):
print("The entered password should have at least one of the symbols $@#_*")
flag = 0
if flag:
return flag


def main():
password = input()

if strong_password_detection(password):
print("The entered password is strong !!")
else:
print("The entered password is weak !!")


if __name__ == "__main__":
main()