If-Else Statements

3 / 4

If we wish to check that a password length is at least 8 and at most 64, we can use the following code:

password = input("Password: ")
n = len(password)
if (n >= 8) and (n < 64):
  print("Password accepted")

The and Python keyword evaluates two Boolean expressions according to the following table:

a\b True False
True True False
False False False

That is, a and b evaluates to True if and only if both a and b evaluate to True.

Boolean 'and'

Input a username and input a password. Check if they equal "JohnDoe" and "Password123!", respectively. If so, print "Access granted"; otherwise, print "Access denied".

Congratulations!

You passed the !

Welcome!

Would you like a guided tour on how to use Vibewise?

Your email has been verified!