Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The dataset file in assets / grades . txt contains a line separated list of people with their grade in a class. Create a regex

The dataset file in assets/grades.txt contains a line separated list of people with their grade in a class. Create a regex to generate a list of just those students who received a B in the course.
import re
def grades():
with open ("assets/grades.txt","r") as file:
grades = file.read()
# Regex pattern to match names followed by a 'B'
pattern = r'\b\w+B\b'
#Find all matches and return a list of names
return re.findall(pattern, grades)
assert len(grades())==16
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In [8], line 1
---->1 assert len(grades())==16
AssertionError:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

Find Vo in the circuit infigure. Is ww 3 k2 2000 Is Vo 12 V

Answered: 1 week ago

Question

=+1. Which of the given are Actions and which are States of Nature?

Answered: 1 week ago

Question

Conduct an effective performance feedback session. page 376

Answered: 1 week ago