Click here to Skip to main content
15,662,426 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
he password should contain at least:
    one upper case letter, and one lower case letter.
    8 characters.
    1 number.


The password should comply with the 3 constraints mentioned earlier. Implement an individual function to check for each constraint. Since the password has to comply with all three of the constraints, you will need to implement one additional function to tie everything together.

Design your program as described below. Complete the docstrings with doctests and any other explanation you deem necessary.

``def check_length(password: str) -> bool:``
   `` Check whether the password contains a least 8 characters.``

``def check_letter(password: str) -> bool:``
    ``Check whether the password contains a least 1 upper case letter and 1 lower case letter.``
``def check_number(password: str) -> bool:``
    ``Check whether the password contains a least 1 number.``

``def check_password(password: str) -> bool:``  

   `` Check whether the password passed all three of the tests.``
``if __name__ == '__main__':``

    ``<Main program, which can only call a single function>``


There is no single correct solution for each of the checks! There’s more than one way to implement each of the functions, so take a look at all of the string operations in the book for inspiration.
Beware! When you check whether a password contains both an upper case letter and a lower case letter, you also need to check whether there is any letter at all.


Ultimately, your program has to produce output like the examples below.

``Provide a password: PotatoTester123``

``The provided password is valid.``

``Provide a password: hello``

``The provided password is invalid.``

What I have tried:

I have tried to do the assignment and keep getting different errors. i would like a step by step how i can do this assignment
Updated 18-Sep-22 7:25am

The answer is the same as I posted at Write a program to determine whether two rectangles are of identical dimensions?[^]. And your time would be better spent by focusing on one assignment at a time.
Share this answer
You're not going to get a step-by-step on how to do this. Doing so would be doing your homework for you and that's not helping you.

What you need to do is provide the code for each function that's going to do a single specific check of the string that's passed to it and returning true or false depending on the result of the check, like checking the string to see if it meets a minimum length requirement.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900