# Logical operators, using regular expressions import re from cs50 import get_string # Prompt user to agree s = get_string("Do you agree? ") # Check whether agreed if re.search("^y(es)?$", s, re.IGNORECASE): print("Agreed.") elif re.search("^no?$", s, re.IGNORECASE): print("Not agreed.")