Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesPython FoundationsModule 3 · Functions and stringsSplit the sentenceswrite51 / 174
+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`
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
📊 Result
Press Run to see result...

💬 Discussion

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