Standardize Mobile Number Using Decorators

  • + 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:]}")