diff --git a/other/password.py b/other/password.py index 6b64bdb4d81a..5a8c0425b490 100644 --- a/other/password.py +++ b/other/password.py @@ -26,9 +26,23 @@ def password_generator(length: int = 8) -> str: # chars_incl= characters that must be in password # i= how many letters or characters the password length will be def alternative_password_generator(chars_incl: str, i: int) -> str: + """ + Generate a password of length `i` containing all characters in `chars_incl`. + + >>> len(alternative_password_generator("abc", 8)) + 8 + >>> alternative_password_generator("abcd", 3) + Traceback (most recent call last): + ... + ValueError: Password length must be at least the number of required characters + """ # Password Generator = full boot with random_number, random_letters, and # random_character FUNCTIONS # Put your code here... + if i < len(chars_incl): + raise ValueError( + "Password length must be at least the number of required characters" + ) i -= len(chars_incl) quotient = i // 3 remainder = i % 3