Dear blog, it’s been a while since my last post haha, but well it’s almost the en of the course!!! yay!! so I need to get this posts done, I’m in a good mood so I have to take advantage of that haha…

Ok here’s Wsq12:

What to Do

Create a program that asks the user for a word which will be your search word and the name of a file to open and search for that word. Then create a function that will receive two parameters (both string) representing those two data points. This function returns the number of occurrences of that word in that file.


You will need to open a file and read the text line by line. This is straight forward in Python since you can treat the file as a list of lines (strings) and iterate over that using a for loop. Check the section “Looping over a file object” in this link for an idea but your book also has this information

The link that Ken provide us was very useful, you should check it out

Also this link help me to understand a little bit more of this files thing in python.

Here are the screenshots of the program and terminal and the code in GitHub as well.



So I hope you can use this, and see you well read you soon!!


CC BY 4.0 #Wsq12 by andreatrejod is licensed under a Creative Commons Attribution 4.0 International License.