for the following question: Find a list of all of the names in the following string using regex. I have written this code:
import re
def names():
simple_string = """Amy is 5 years old, and her sister Mary is 2 years old.
Ruth and Peter, their parents, have 3 kids."""
names= re.findall("[A-Z][a-z]*", simple_string)
print(names)
print(len(names))
names()
It gives the correct output like this:
**['Amy', 'Mary', 'Ruth', 'Peter'] , 4**
However when I use this :
**assert len(names()) == 4, "There are four names in the simple_string"**
it gives me this error:
**object of type 'NoneType' has no len()**
I don't know where is the error in function names, can anybody help?
note: I can't change the assert function, it's inside the question.