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.
def grades():
with open ("assets/grades.txt", "r") as file:
grades = file.read()
for line in grades:
line = line.rstrip()
if re.search('^X\S*: [0-9.]+', line):
print(line)
assert len(grades()) == 16
The easy solution is to add the following regular expression '([A-Z][a-z]+ [A-Z][a-z]+): B'. this solution is provided from abd-elrhman-mohey
I can see where you did go wrong my friend
first of all grades it's the lines u don't need the for loop to get them second of all, I don't know why did u use '^X\S*: [0-9.]+' as it seems out of what u want you need to see if the grades ar numbers or normal grades (A B C D) and appears from the question that u need to get B so we can say the final code will be for the find
and final code I guess will be