Introduction
Quiz
3. Question 2
Summary

Instruction

Amazing! The next question is about file operations.

Exercise

Write a function named count_word(file_name, word) that opens a file with its name given as the first argument and reads that file line by line. Each line contains a single word. The function returns the number of lines that contain the word given as the second argument.

Stuck? Here's a hint!

If you use a for loop like this:

for line in file_name:

Remember that each line with a word will have '\n' (the newline character) at the end.