Created
February 23, 2016 19:33
-
-
Save Xotabu4/b02e1a35bf40a91518a4 to your computer and use it in GitHub Desktop.
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
| # coding=utf-8 | |
| file = open('C:\\file.txt', 'r', encoding ='utf-8') | |
| lines = file.readlines() | |
| file.close() | |
| number_of_words_per_line = [] | |
| for line in lines: | |
| line.replace(".","") | |
| line.replace(",","") | |
| line.replace("!","") | |
| line.replace("?","") | |
| line.replace("(","") | |
| line.replace(")","") | |
| line.replace('"',"") | |
| words_in_line = line.split() | |
| number_of_words_per_line.append(len(words_in_line)) | |
| print(number_of_words_per_line) | |
| total_words = 0 | |
| for number in number_of_words_per_line: | |
| total_words += number | |
| print(total_words/len(lines)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment