Skip to main content

Unit 3 · Decisions, Decisions · Lesson 31 of 57

Project: Password Bouncer

Project time!

Amer keeps signing up for things with terrible passwords, so we're building a bouncer that rates them before he's allowed to use one.

What it should do

Make a function called rate_password that takes a password and returns one of these strings:

If the password...Return
contains amer anywhere"Nice try, Amer."
is shorter than 8 characters"Too short"
is 8 to 11 characters"Okay"
is 12 or more characters"Strong"

The Amer rule beats everything else. Even amerisaverysecurepassword gets "Nice try, Amer."

One more new trick: in asks whether one string is inside another:

print("amer" in "amer123")
print("amer" in "zain123")
True
False

Then, under your function:

  1. Ask for a password with input()
  2. Print what rate_password gives back

Build the password bouncer!

Python exercise

Write the program in an editor next to the lesson, run it, and have it checked automatically. Create a free account to do this part.

Do this lesson for real

With a free account you get the terminals, challenges and checks that go with the lessons in Intro to Python, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.