Mates I am trying to solve the assignment 1
Question :
Part B
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.?
My Solution
import re
def grades():
with open ("assets/grades.txt", "r") as file:
grades = file.read()
# YOUR CODE HERE
namesB=[ ]
for item in re.finditer("(?P<name>.*)(\: B)",grades):
namesB.append(item.group('name'))
return namesB
raise NotImplementedError()
grades()
assert len(grades()) == 16
I suppose to get 16 PEOPLE WHO GOT B in their course but it shows only 1 guy in the out put i dont understand wts wrong with my codes… Mates help plz