Intermediate
Wrap retrieved text as data
Write wrap_sources(chunks) where each chunk is a dict with id and text. Return one string with one line per chunk, joined by a newline: <source id="ID">TEXT</source>.
Before putting the text in, escape & as &, then < as < and > as > (in this order), so a passage cannot close the tag or open a new one.
What Check tests
- Wraps one chunk
- Puts each chunk on its own line
- A passage cannot close the tag
- Ampersands are escaped first
- No chunks gives an empty string
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.