Objective
Create a Python program with a decorator that receives a parameter: it needs three levels of functions.
Instructions
- Define
def repeat(times), which returns a decorator. That decorator receives a function and returns awrapper(*args, **kwargs)that calls the original functiontimestimes in a row. - Define
say_hello(name), which showsHello, NAME, and decorate it with@repeat(times). Sincetimesis read from the input, apply the decorator by hand:say_hello = repeat(times)(say_hello). - Read the number of times on the first line and the name on the second.
3
Ana
Hello, Ana
Hello, Ana
Hello, Ana
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise