Problem 1 (100pts): choose
Throughout the project, we will be making changes to functions in cats.py
.
Implement choose
, which selects which paragraph the user will type.
It takes a list of paragraphs
(strings), a select
function that returns True
for paragraphs that can be selected, and a non-negative index k
.
The choose
function returns the k
-th paragraph for which select
returns True
.
If no such paragraph exists (because k
is too large), then choose
returns the empty string.
Hint: Index starts from
0
.
Before writing any code, unlock the tests to verify your understanding of the question:
$ python ok -q 01 -u
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
$ python ok -q 01