A message can contain the right words but still be awkward to compare: " Beacon Dim " has extra spaces and mixed capitalization.
A string method is an operation called after the string, using a dot. Here are two that help:
strip() removes whitespace from the beginning and end.lower() turns uppercase letters into lowercase letters.You can chain them. In message.strip().lower(), Python strips the spaces first, then lowercases that result. It doesn't change the original message.
cleaned to message with its surrounding whitespace removed and its letters lowercased.In main.py, the .strip() call is already supplied. Add the remaining method, Run to see beacon dim, then Submit.
Two more methods will help with the next notice. replace(old, new) returns a string with matching text replaced; startswith(prefix) returns True or False.
status = "gate closed"
print(status.replace("closed", "open"))
print(status.startswith("gate"))
print(status)
Run this example to see gate open, True, and the unchanged gate closed. Replacing text creates a new string; it doesn't rewrite status.