Login and get codingWrite a decorator called
strip_range
that replaces characters with dots. It takes a start and an endint
argument that defines the range of characters to be replaced. These work likerange
, so start is inclusive and end is exclusive.Best to illustrate with an example: decorating the
gen_output
function below, assumingtext
holds 'Hello world', it should convert it to 'Hel.. world' (= replace 0-indexed positions 3 and 4)@strip_range(3, 5) def gen_output(text): return textSee
test_strip_range
for more examples that have to pass in order to get credit. Good luck!New to decorators? Check out our Learning Python Decorators by Example article and/or start with two decorator Bites that are probably a bit easier: #41. Write a login_required decorator and #120. Write a numbers validation decorator. A similar decorator-with-argument Bite is: #22. Write a decorator with argument.
177 out of 179 users completed this Bite.
Will you be the 178th person to crack this Bite?
Resolution time: ~55 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 6.27 on a 1-10 difficulty scale.
» Up for a challenge? 💪