We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

# Standardize Mobile Number Using Decorators

# Standardize Mobile Number Using Decorators

#### Sort by

recency

#### |

#### 208 Discussions

#### |

Please Login in order to post a comment

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 wrapper(f): def fun(l): striped = sorted([i[-10:] for i in l]) for i in striped: print("+91 "+i[0:5]+" "+i[5:]) return fun** **

def wrapper(f): def fun(l): striped = sorted([i[-10:] for i in l]) for i in striped: print("+91 "+i[0:5]+" "+i[5:]) return fun

Python Solution