

Cloud Diary
Your cloud diary has grown long. Write filter_diary(entries, query) that returns every entry containing the query, keeping the diary's order.
The search ignores case, so "cloud" finds "Puffy Cloud today". It also ignores spaces around the query. A blank query matches nothing, because searching for nothing should not dump the whole diary.
Build it step by step
- Clean the query: trim it and lower-case it.
- If the cleaned query is empty, return an empty list straight away.
- Loop over the entries and keep the ones whose lower-case text contains the query.
Examples
filter_diary(['Saw a cyan cloud', 'Had a starry dream', 'Puffy Cloud today'], 'cloud')
→ ['Saw a cyan cloud', 'Puffy Cloud today']
filter_diary(['Clear skies', 'Sunset was magenta'], 'rain')
→ []
project.py
PYTHON
Saved as you type
Tests
0 of 4 passing- •finds 'cloud' twicefilter_diary(['Saw a cyan cloud', 'Had a starry dream', 'Puffy Cloud today'], 'cloud')expected ['Saw a cyan cloud', 'Puffy Cloud today']
- •no matchfilter_diary(['Clear skies', 'Sunset was magenta'], 'rain')expected []
- •query in capitalsfilter_diary(['rain again', 'sunny'], 'RAIN')expected ['rain again']
- •blank query matches nothingfilter_diary(['anything'], ' ')expected []
On the line
+220 XP
Pass all 4 tests to claim it.
