Counting Words from a File

Learn how to read the number of words in a file.

Previously, we learned how to read a file and then print it onto the screen. Now, let’s take another step forward and count the number of words present in a file. Let’s look at the code widget at the end of the lesson.

Lines 3-5 should be familiar by now. First, we’ll open the file, read it, and print ...