A tiny password strength checker that looks only at the length of the password.
You start with:
password = "Secret99"
Build:
Password length: 8 OK
Rules:
- Collect the output lines in a variable named
receipt: one string with the lines joined by"\n"(for example build a listlinesand join it). The grader printsreceiptfor you, so do not callprint. - Add the line
"Password length: "followed by the number of characters. - If the length is at least 8, add the line
OK; otherwise add the lineToo short.
Try other passwords: with abc the output is
Password length: 3 Too short
Use
len(password) to get the length and str(...) to concatenate it with a string.
password = "Secret99"
length = len(password)
lines = []
lines.append("Password length: " + str(length))
if length >= 8:
lines.append("OK")
else:
lines.append("Too short")
receipt = "\n".join(lines)
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
