Part of the series

Several example codes

~1 min read • Updated Oct 11, 2025

Program Overview

This Python program receives a sample statement and checks whether Sally has taken her bag.
For simplicity, we assume the input is a string describing the situation.
If the string contains the word "taken", the program concludes that Sally has taken her bag.


Python Code:


def did_sally_take_her_bag(statement: str) -> bool:
    return "taken" in statement.strip().lower()

# Run the program
sample_input = input("Enter Sally's bag status: ")

if did_sally_take_her_bag(sample_input):
    print("Sally has taken her bag.")
else:
    print("Sally has not taken her bag.")

Sample Output (input: "Sally has taken her bag"):


Sally has taken her bag.

Step-by-Step Explanation:

- The user enters a sentence describing Sally’s bag status
- The program trims whitespace and converts the string to lowercase
- It checks whether the word "taken" is present
- Based on the result, it prints whether Sally has taken her bag or not


Written & researched by Dr. Shahin Siami