Created
February 17, 2020 01:54
-
-
Save nenkoru/00c98f43e80a86542c587c58a66703db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FormatTelephone: | |
def __init__(self, | |
phone, | |
mask="+* (***) ***-**-**", | |
maskSymbol="*"): | |
self.phone = phone | |
self.maskSymbol = maskSymbol | |
self.mask = mask | |
def parseMask(self): | |
retlst = [] | |
for x in range(0, len(self.mask)): | |
if self.mask[x] == self.maskSymbol: | |
retlst.append(x) | |
return retlst | |
def parsePhone(self): | |
pass | |
def do(self): | |
indexes = self.parseMask() | |
phone = list(self.mask) | |
for x in range(0, len(self.phone)): | |
phone[indexes[x]] = self.phone[x] | |
return phone | |
print("".join(phone)) | |
form = FormatTelephone("79129385839") | |
form.do() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment