Step 1

Write some lorem ipsum text into a file. You can do this manually.

Read the file1 using Python and make a statistic of how often every word appears in the file2 and print your results to the command line.

Step 2

Now parameterize the function.3

Make the main function peek into sys.argv4 and use all arguments to the script as input file names5, combining the results6.

  1. When opening files you can easily just iterate over the lines in the file by iterating over the filehandler object itself. 

  2. You can/should use a dict containing every word as a key and as the value a counter then scan the text incrementing the respective counters[^counter] 

  3. Let the function take parameters as an input. 

  4. You have to use import sys to have access to sys.argv

  5. The first argument of sys.argv is always the script itself. 

  6. You can easily return multiple things by using return value1, value2, value3 and so on, which returns a tuple (value1, value2, value3)