Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_char(text, char):
- count = 0
- for c in text:
- if c == char:
- count += 1
- return count
- filename = input("Enter a filename: ")
- with open(filename) as f:
- text = f.read()
- for char in "abcdefghijklmnopqrstuvwxyz":
- perc = 100 * count_char(text, char) / len(text)
- print("{0} - {1}%".format(char, round(perc, 2)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement