Standardize Mobile Number Using Decorators

Sort by

recency

|

218 Discussions

|

  • + 0 comments
    def fun(l):
        li = []
        for i in l:
            if len(i) == 10:
                x = i[0:5] + i[5:]
                li.append(x)
            elif len(i) > 10 and i[0] == "0":
          
                y = i[1:6] + i[6:]
                li.append(y)
            elif len(i) > 10 and i[0] == "+":
      
                w = i[3:8] + i[8:]
                li.append(w)
            else:
    
                z = i[2:7] + i[7:]
                li.append(z)
        
        li.sort()  # Sort the numbers
        
        for j in li:
            p = str(j)
            print(f"+91 {p[0:5]} {p[5:]}")
    
  • + 0 comments
    def wrapper(f):
        def fun(l):
            m= [f"+91 {num[-10:-5]} {num[-5:]}" for num in l]
            return f(m)      
        return fun
    
  • + 0 comments
    arr = []
            for i in l:
                m_num = i[-10:]
                arr.append(m_num)
            arr = sorted(arr)
            for j in arr:
                a = j[:5]
                b = j[5:]
                print("+91 "+str(a)+" "+str(b))
    
  • + 0 comments
    def wrapper(f):
        def fun(l):
            # complete the function
            return f([f"+91 {string[-10:-5]} {string[-5:]}" for string in l])
        return fun
    
  • + 0 comments

    def wrapper(f): def fun(l, *args): # complete the function l = [str(i)[-1: -11: -1][::-1] for i in l] out = ["+91 "+ str(i[:5]) + " " + str(i[5:]) for i in l] out = f(out) return fun