Skip to content

Instantly share code, notes, and snippets.

@nenkoru
Created February 17, 2020 01:54
Show Gist options
  • Save nenkoru/00c98f43e80a86542c587c58a66703db to your computer and use it in GitHub Desktop.
Save nenkoru/00c98f43e80a86542c587c58a66703db to your computer and use it in GitHub Desktop.
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