Files

36 lines
839 B
Markdown

---
type: challenge
title: "The Counter"
xp: 75
duration: 30
difficulty: 3
---
# The Counter
> **[INCOMING — Mission Control, Earth]**
>
> Cadet, time to count things in text. Three counts:
>
> - **Total length** — `len(s)`
> - **Word count** — `len(s.split())` (split breaks on whitespace)
> - **`a` count** — `s.lower().count("a")` returns how many `a`s
>
> Implement `count(s)` that returns a dict with three keys:
>
> - `length` — total chars including spaces
> - `words` — word count
> - `a_count` — number of lowercase `a`s after lowercasing
>
> [END TRANSMISSION]
## Your Task
In `starter/starter.py`, build the dict using `len()`, `.split()`,
`.lower()`, `.count()`.
## Objectives
- `count("Hello andromeda")``{"length": 15, "words": 2, "a_count": 2}`
- All three keys present and correct for any sentence