p
y
c
h
a
l
l
e
n
g
e
r
Home
Intermediate Python
Decorators
Exercise: Decorator with a parameter
Exercise: Decorator with a parameter
Build
repeat(times)
: it returns a decorator that calls the wrapped function
times
times and returns the list of results.
reset
def repeat(times): # return a decorator that calls # the wrapped function `times` times # and returns the list of results pass @repeat(3) def hi(): return "hi"
print(hi()) # ['hi', 'hi', 'hi']
Python
Setting up Python environment...
Output