Intermediate
Guard a model's rewrite
A model was asked to rewrite a question. Write accept_rewrite(reply, original, max_words=12) that returns the reply (with surrounding whitespace removed) only if it is not empty, has no line break inside it, and has at most max_words words. Otherwise it returns original.
What Check tests
- A good reply is accepted and trimmed
- An empty reply falls back
- A reply of only spaces falls back
- A long reply falls back
- A multi-line reply falls back
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.