Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part III: Create a Business Card (20 points) Write a function business card (),

ID: 3720345 • Letter: P

Question

Part III: Create a Business Card (20 points) Write a function business card (), which takes a single argument contact info that contains the contact information for a person. After validating the format of the argument, the function creates a new string that reformats the input in a particular way (described later). CSE 101 – Spring 2018 Lab #13 Lab #13 Page 5 A validly formatted contact info string is defined by the following components, in the given order: 1. the string ' *N' 2. exactly one space 3. a person's name, defined as a single uppercase letter, followed by any combination of uppercase letters, lowercase letters and spaces 4. exactly one space 5. the string ' *P' 6. exactly one space 7. exactly 10 digits 8. exactly one space 9. the string '*T' 10. exactly one space 11. a person's job title, defined as a single uppercase letter, followed by any combination of uppercase letters, lowercase letters and spaces

Explanation / Answer

import re
def business_card(contact_info):
pat = re.compile(r"*Ns[A-Z]{1}[a-zA-Zs]*s*Ps[0-9]{10}s*Ts[A-Z]{1}[a-zA-Zs]*")
pat1=(pat.search(contact_info).group())
pat2=pat1.split("*P")
pat3=pat2[0].split("*N")[1]
pat4=pat2[1].split("*T")[1]
pat5=pat2[1].split("*T")[0]
pat6="("+pat5[1:4]+") "+pat5[4:7]+"-"+pat5[7:]
print("Name: "+pat3+", "+"Title: "+pat4+", "+"Phone: "+pat6)
  
business_card('*N Harik kis Ross *P 1004253222 *T Systems Administrator')
  

output:

C:UsersHarikaDesktop>python chegg_re_business.py
Name: Harik kis Ross , Title: Systems Administrator, Phone: (100) 425-3222

please let me know if you did not understand anywhere.