def format_phone(phone):
    """
    Format a string as a phone number.
    """
    if len(phone) == 10:
        return "(" + phone[:3] + ") " + phone[3:6] + "-" + phone[-4:]
    else:
        return phone