We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defminimumNumber(n,password):# Return the minimum number of characters to make the password stronglen_required=6has_digit=Falsehas_lower_case=Falsehas_upper_case=Falsehas_special_char=Falsespecial_char=set("!@#$%^&*()-+")char_required=4foriinpassword:if"0"<=i<="9"andnothas_digit:has_digit=Truechar_required-=1elif"a"<=i<="z"andnothas_lower_case:has_lower_case=Truechar_required-=1elif"A"<=i<="Z"andnothas_upper_case:has_upper_case=Truechar_required-=1elifiinspecial_charandnothas_special_char:has_special_char=Truechar_required-=1ifn>=len_required:returnchar_requiredlen_diff=len_required-nreturnlen_diffiflen_diff>char_requiredelsechar_required
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strong Password
You are viewing a single comment's thread. Return to all comments →