Standardize Mobile Number Using Decorators

Sort by

recency

|

213 Discussions

|

  • + 0 comments
    def wrapper(f):
        def fun(l):
            l = [f"+91 {x[-10:-5]} {x[-5:]}" for x in l]
            f(l)
        return fun
    @wrapper
    def sort_phone(l):
        print(*sorted(l), sep='\n')
    if __name__ == '__main__':
        l = [input() for _ in range(int(input()))]
        sort_phone(l)
    
  • + 0 comments
    from re import sub
    def wrapper(f):
        def fun(l):
            return f([sub(r"(.*){0,3}(\d{5})(\d{5})$",\
            r"+91 \2 \3", num)for num in l])
        return fun
    
  • + 0 comments
    
    
    def fun(l):
        formatted_numbers = ["+91 " + num[-10:-5] + " " + num[-5:] for num in l]
        f(formatted_numbers)
    return fun
    
  • + 0 comments

    def wrapper(f): def fun(l): return f(j[::-1] for j in [i[:-11:-1][:5]+ " " + i[:-11:-1][5:] +" 19+" for i in l]) return fun

  • + 0 comments
    from re import sub
    
    def wrapper(f):
        r = r"^(?:\+?91|0)??(\d{5})(\d{5})$"
        s = r"+91 \1 \2"
        
        def fun(li):
            return f([sub(r, s, i) for i in li])
        return fun