Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def countChar(text,char):
- count = int()
- for c in text:
- if c == char:
- count += 1
- return count
- filename = input("Enter file to analyze: ")
- char = input("What character do you want to count?: ")
- with open(filename, 'r') as fi:
- text = fi.read()
- print(countChar(text,char))
Add Comment
Please, Sign In to add comment