Simple password rules

From Computer Science Wiki
This a problem set for you to work through [1]

This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the bottom of this page, but please don't look at it until you have tried (and failed) at least three or four times.

The Problem[edit]

This problem is designed to test your skill and knowledge of strings, specifically your knowledge and understanding of testing if strings are a certain length, contain numbers, etc...

Please write a simple program that asks the user to enter a password and confirm a password. The password must be at least 8 characters long, have one uppercase character, and have at least one symbol. Of course, the original password must match the confirmation password. :-)

Some Code to Get You Started[edit]

# this is my password rules application

print ('''Please enter a password. 

The password must: 
    
    1. have 8 characters of more
    2. have at least one upper-case letter
    3. have at least one symbol
    
    ''')
user_password = raw_input("Please enter your password: ") 
confirm_user_password  = raw_input("Please confirm your password: ")   

# the first check will be to see if the passwords match. 

if user_password == confirm_user_password:
    print("foo")
    # let's see if the password is at least 8 charatcers. I wonder how we would do that? 
    # 
else: 
    print("Hey. Your passwords do not match.")

Take This Farther[edit]

This simple program is very useful, and it is likely that you have used a function when you register for a web service.

  • password rules should be customizable! Make a configuration form that asks the user how long the password should be, how many uppercase characters it should have, and how many symbols, and then apply those rules to your password form, above.

How you will be assessed[edit]

Every problem set is a formative assignment. Please click here to see how you will be graded

References[edit]

One Possible Solution[edit]

Click the expand link to see one possible solution, but NOT before you have tried and failed!

not yet!