<a id="ch-07"></a>

## Chapter 7 — Sam is a substring, not a directory

<!-- open-cyber-academy:lesson-figures:start ch-07 -->
### Lesson map

Lesson 07. Map, example, EX053.

```mermaid
flowchart TD
  K["Key text form owner Sam"] --> T{"Is the character sequence Sam inside it?"}
  T -->|Yes| F["Failure label"]
  T --> Q{"Did the script open a staff list?"}
  Q -->|No| R["The test is text only"]
```

The letters decide. A person record is not consulted.

### Logical drawing

```text
tested string
  form owner Sam
sought sequence
  Sam
case
  capital S
not consulted
  a staff list
  a deputy named later
```
<!-- open-cyber-academy:lesson-figures:end ch-07 -->

### Learning outcomes

After this chapter, you should be able to:

1. Point at the characters the test searches.
2. Separate that search from a staff lookup.
3. Refuse a deputy's name that the script never stored.

### 7.1 The operator looks for characters. It does not know who Sam is.

`"Sam" in d` is true when the key contains the capital letters S, a, m in that order. The key `form owner Sam` contains them, so the test is true. The same test on `coordinator inbox` is false, which is why that line depends on the length test instead. The comparison is case-sensitive. A key written `form owner sam` would not satisfy this particular search. This file does not contain that lowercase key.

The script has no list of staff, no holiday calendar, and no field for a deputy. Sam Okafor is the volunteer in the case notes. The letters in the key happen to spell his given name. That coincidence is not a query. When the notes later say a second person should own the form, those notes do not edit `d`, and they do not remove the failure label from the embedded print. The lab still shows the single owner it was given.

A key such as a word that merely contained those three letters would also trip the test. This run has no such extra key, and this chapter does not add one. The limit stands: the flag is a text test, not an identity check.

| Object | Role |
|---|---|
| `form owner Sam` | The key that contains the sequence |
| `"Sam" in d` | A case-sensitive character test |
| A deputy | Prose, not a variable |
| A staff directory | Absent from the file |

### 7.2 Worked example

| Offered sentence | What the file supports | Decision |
|---|---|---|
| "The form line trips because the key contains Sam." | The substring test | Keep |
| "The inbox key does not contain that sequence." | Length is its reason | Keep |
| "The script looked Sam up and found he is on holiday." | No directory and no date | Refuse |
| "Naming a deputy clears the printed flag." | The print is unchanged | Refuse |

> **Synthetic case.** The key is a string in a classroom list.

### Errors and limits

Do not promote a character test into a personnel decision.

### Apply

- **EX053 — Substring.** What makes `form owner Sam` a failure when it has only one source, and does the script store a deputy? *Rubric:* 3 = the key contains the capital sequence Sam; the length test is false for that one name; no staff list and no deputy are stored;; 2 = the flag is a character test and the deputy is absent;; 1 = the name only;; 0 = none.

<!-- open-cyber-academy:chapter-navigation:start ch-07 -->
### Continue studying — lesson 07 (chapter 07 of 20)

[← Chapter 06](#ch-06) · [Course chapter index](../SUBJECTS.md) · [Chapter 08 →](#ch-08)

Continue to the next authored lesson.
<!-- open-cyber-academy:chapter-navigation:end -->

## Worked answers

<a id="answer-ex053"></a>
**EX053.** The key contains the capital sequence Sam, and the length test is false for that single name. The script stores no staff list and no deputy.
