def print_file_stats(filename): """ Prints different statistics about the provided file :param filename: (str) the name of the file to provide stats on :return: (None) """ file = open(filename, "r") longest = "" shortest = "" total_length = 0 count = 0 for line in file: line = line.strip() words = line.split() for word in words: if len(word) > len(longest): longest = word if shortest == "" or len(word) < len(shortest): shortest = word total_length += len(word) count += 1 file.close() print("Number of words: " + str(count)) print("Longest word: " + longest) print("Shortest word: " + shortest) print("Avg. word length: " + str(total_length / count))