Junior — Senior
Timer implemented as a context manager
livecode
Task condition
It is necessary to create a Timer class that works as a context manager. When entering the with statement, the time measurement begins, and upon exiting the block, the calculated time is stored in the attribute elapsed.
with Timer() as t:
time.sleep(1)
print(t.elapsed)