def phone_format(n):
    return format(int(n[:-1]), ',').replace(',', '-') + n[-1]
phone_format('5555555')
phone_format('5555555')
phone_format('5555555555')
phone_format('18005555555')
What's the best way to format a phone number in Python?