Question
In Python do the following: A: The text below misses a separator between the course and the grades. Create a regular expression to extract all
In Python do the following:
A: The text below misses a separator between the course and the grades. Create a regular expression to extract all the grades from the text and assign that value to the variable avg_grade.
text = """Intro_to_Python6.5 Calculus8.0 Advanced_deep_learning8.3 Compiler_construction6.0 """
Using:
regex = re.compile(pattern, flags=re.IGNORECASE) result = regex.findall(text)
B: Write a regular expression that extracts the sender, recipient and the subject from the email.
text = """From: Adam To: my classmates Subject: We can do better! Body: Focus hard, and we will be fine. """
Using the output:
print('{} says "{}" to {}'.format(result[0], result[2], result[1]))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started