Over 10 Million Study Resources Now at Your Fingertips


Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Language:EN
Pages: 3
Words: 418

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.

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Payment
Make payment
Document download
Download File
PageId: ELIB5558C1
img
Uploaded by :
YnqOebAj
Page 1 Preview
step by step answers with explanation
Sell Your Old Documents & Earn Wallet Balance