Language:EN
Pages: 3
Words: 418
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
step by step answers with explanation

Find Professors' Names Regex Homework Answers Needed

Your Question:

use regular expression in python to find the following:

10 students were enrolled in the first year with Prof. Tom Chan as the chairperson. Professor Xihuang Chen succeeded Prof. Tom Chan and become the chairmanship. Professor Sik-lum Chan was inaugurated as the Department chairman. Professor Lee Yee Lam was inaugurated as the Department chairman.

Professor Lee Yee Lam

Step By Step Answers with Explanation

To find the names of the professors who became chairpersons in the given text using regular expressions in Python, you can use the `re` module. Specifically, we will use the `re.findall()` function to extract the names. Here's a step-by-step explanation of how to achieve this:

# We'll look for the pattern "Professor [First Name] [Last Name]".

pattern = r'Professor ([A-Z][a-z]+ [A-Z][a-z]+)'

    print(match)

Output:

Explanation of the code:

1. Import the `re` module for regular expressions.

- `[A-Z][a-z]+`: Matches an uppercase initial letter followed by one or more lowercase letters (first name).

- ` ` (space): Matches the space between the first and last names.

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Jesus Lutz

PageId: ELIB5558C1