Write a Python program that takes a directory as a required argument and a filename extension as optional argument that defaults to “.txt”. The program should locate all files with the given extension in the given directory and all its subdirectories to produce a list of all matching files with the numbers of files within the file. The program should also output the total number of lines and the average number of lines per file.
For example:
./file1.txt 10
./file2.txt 25
./d1/d1fa.txt 5
./d1/d1fb.txt 37
===============
Number of files found: 4
Total number of lines: 77
Average lines per file: 19.25