****IN PYTHON! Write a function named file_stats that takes one string parameter (in_file) that is the name of an existing text file. The function file_stats should calculate three statistics about in_file: the number of lines it contains, the number of words and the number of characters, and print the three statistics on separate lines. For example, the following would be the correct input and output: >>> file_stats('created_equal.txt') lines 2 words 13 characters 72 Note: The number of characters may vary slightly between operating systems. Similarly, the number of lines may vary by 1 line, depending on the method used to calculate it. I attached a picture of my code so far and a picture of what the text file reads.
****IN PYTHON!
Write a function named file_stats that takes one string parameter (in_file) that is the name of an existing
text file. The function file_stats should calculate three statistics about in_file: the number of lines it
contains, the number of words and the number of characters, and print the three statistics on separate
lines. For example, the following would be the correct input and output:
>>> file_stats('created_equal.txt')
lines 2
words 13
characters 72
Note: The number of characters may vary slightly between
may vary by 1 line, depending on the method used to calculate it.
I attached a picture of my code so far and a picture of what the text file reads.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images