Help with exercise 11.1 from the book ''Python for Everybody'''

I found out what it was. The problem was that some lines in the file have a whitespace in the end, including the line 325, which I gave as an example of the lines ‘grep’ wasn’t matching. So when I put the line “line=line.strip()” in my code, I was getting rid of these blank spaces, so increasing the number of matches. Now, when I ask ‘grep’ to find ‘java\s*$’, he finds exactly the number of 4218 matches.

Thank you for being so helpful!

1 Like