seed: curriculum content
This commit is contained in:
35
1.solar-system/3.strings/06.the-counter/index.md
Normal file
35
1.solar-system/3.strings/06.the-counter/index.md
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
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
|
||||
Reference in New Issue
Block a user