import time # Measure the excution time of a given function def time_decorator(func): def wrapper(*args, **kwargs): begin_time = time.time() output = func(*args, **kwargs) end_time = time.time() print(f"Execution time of function {func.__name__}: {round(end_time - begin_time, 2)} seconds.") return output return wrapper # Categorize the total amount of each transaction @time_decorator def group_txn_price(data): for txn in data: price = txn['totalAmt'] if 0 <= price <= 1500: txn['totalAmtCat'] = 'Low' elif 1500 < price <= 3500: txn['totalAmtCat'] = 'Moderate' elif 3500 < price: txn['totalAmtCat'] = 'High' return data txn_list = group_txn_price(txn_list) # Output # Execution time of function group_txn_price: 0.26 seconds.