354-8 Why is the code for return first 10 matches on this screen?

hi, i am struggling to understand how the first+10_matches function apply here. it looks like it is calling straight all the matches isn’t it?

def first_10_matches(pattern):
    """
    Return the first 10 story titles that match
    the provided regular expression
    """
    all_matches = titles[titles.str.contains(pattern)]
    first_10 = all_matches.head(10)
    return first_10

pattern = r"[Jj]ava[^Ss]"
java_titles = titles[titles.str.contains(pattern)]

The function isn’t an essential part to completing the mission. This is just one way that we can test our pattern to see if it’s returning the matches the way we want it to. When you’re working on other projects, you may want to be able to test the pattern first by seeing a small sample, so they’ve given you an example function you can use. Once you have the pattern, you don’t need the function anymore!

1 Like

Yup, got it. misunderstand the instruction there:grinning:

1 Like