Skip to main content
← CoursesPython FoundationsModule 3 · Functions and stringsSplit the sentenceswrite48 / 170
💬 Discuss🧪 Playground+75 XP
Task
📝 **Task:** `word_count(text)` returns word count via `split()` + `len()`. 📋 **Steps:** 1. `def word_count(text):` 2. Split via `.split()` → list of words 3. Return `len(...)` of that list 💡 **Similar example (lines):** ```python def line_count(text): return len(text.split("\n")) print(line_count("first\nsecond\nthird")) # 3 ``` ⚠️ `.split()` with no args splits on any whitespace. 🎯 **Expected output:** `3`

Keep going

✏️ Write your code here
🐍
Loading Python...
First visit only — ~5-10s. Stays cached afterward.
📊 Result
Press Run to see result...
📣 Help someone learn PythonShare this lesson with a friend — the first 15 are free, no signup.Tweet

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…