I have a simple python action that I want to take. I have a string. something like
2364968438
-
236-496-8438
def numberfy(request, number):
phone =
#code that splits the number and adds hyphen goes here
return phone
Splice it and join it (if your input is already validated):
def dashify(num):
s = str(num)
return '-'.join([s[:3], s[3:6], s[6:]])
For example:
>>> dashify(2364968438)
'236-496-8438'