Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. count1 = 0
  2. count2 = 0
  3. with open('text.txt', encoding='utf-8') as f:
  4.     for line in f:
  5.         words = line.split()
  6.         count2 += len(words)
  7.         for word in words:
  8.             if not word.endswith(('.', ',')):
  9.                 count1 += 1
  10. print("percentage is ", '{:.3f}'.format(count1 / count2 * 100), "%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement