Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Clean and standardise a list of phone numbers
- def clean_numbers(nlist):
- newlist = []
- for x, ins in enumerate(nlist):
- outs, x = "", -1
- while len(outs) < 10:
- if ins[x].isdigit():
- outs = ins[x] + outs
- x -= 1
- newlist.append("+92" + outs)
- return newlist
- number_list = [' 03336482191', '3017651141', ' 0335-7588669', '923009772069']
- print(clean_numbers(number_list))
- # Output:
- # ['+923336482191', '+923017651141', '+923357588669', '+923009772069']
Add Comment
Please, Sign In to add comment