Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- count1 = 0
- count2 = 0
- with open('text.txt', encoding='utf-8') as f:
- for line in f:
- words = line.split()
- count2 += len(words)
- for word in words:
- if not word.endswith(('.', ',')):
- count1 += 1
- print("percentage is ", '{:.3f}'.format(count1 / count2 * 100), "%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement