Standardize Mobile Number Using Decorators

  • + 0 comments

    The other solutions here did nothing to help me actually understand decorators. Yes you can just completely replace the print statement in sort_phone(l)/f(l) by putting one in fun(l), but I don't think that's the intended solution or what decorators are usually used for. Here's another solution:

    def wrapper(f):

    def fun(l):
        l = ['+91 '+num[-10:-5]+' '+num[-5:] for num in l]
        return f(l)
    return fun