Created
September 29, 2013 13:49
-
-
Save figengungor/6752683 to your computer and use it in GitHub Desktop.
A function that reads a file and returns the number of lines and words in the file as a tuple.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def number_of_lines_and_words_of_the_file(filename): | |
| f = open(filename) | |
| lineNo=0 | |
| wordNo=0 | |
| for line in f: | |
| wordNo+=len(line.split(" ")) | |
| lineNo+=1 | |
| return lineNo, wordNo | |
| print number_of_lines_and_words_of_the_file("series.txt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment