<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># 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 &lt;last-name&gt;, &lt;first-name&gt;

   full_name: a string with the form &lt;first-name&gt; &lt;last-name&gt; 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 "&lt;last-name&gt;, &lt;first-name&gt;"
   return last+', '+first
</pre></body></html>