# name_phone.py

""" Examples used in Lecture 6 """


def get_campus_num(phone_num):
    """Returns: the on-campus version of a 10-digit phone number.

    Returns a str of the last 5 digits in the form "X-XXXX"

    phone_num: phone number w/area code
    Precondition: phone_num is a 10 digit string of only numbers
    """
    return phone_num[5]+"-"+phone_num[6:10]


def last_name_first(full_name):
   """Returns: copy of full_name in the form <last-name>, <first-name>

   full_name: a string with the form <first-name> <last-name> with one or more
   blanks between the two names
   """
   #get index of space after first name
   space_index = full_name.index(' ')

   #get first name
   first = full_name[:space_index]

   #get last name
   last  = full_name[space_index+1:]

   #return "<last-name>, <first-name>"
   return last+', '+first
