From the course: Python: Decorators
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Challenge: Decorators with arguments - Python Tutorial
From the course: Python: Decorators
Challenge: Decorators with arguments
(upbeat music) - [Instructor] So for this challenge write a decorator called munch that replaces the characters from the string Fibonacci with X so it munches away at the string. Hence the name. It takes the start and end arguments. Both of these need to be integers that defines the range of characters to be replaced with X. So the start and the end work like the Python in-built function, range. So start is inclusive and end is exclusive. So for example, if we pass arguments one and four, we'll get the following output. And with the arguments zero and 10, we'll just get nine Xs. And that's because we're replacing or munching away at all the nine characters of the string Fibonacci. Use munch.py as your starting point. This challenge should take you about 10 minutes.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.