Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- '''
- Created on 03-09-2011
- @author: Maciej Czekaj
- '''
- import string
- def count_chars(file):
- count = {}
- counter = 0
- for i in range(len(file)):
- if file[i] in string.letters:
- if file[i] in count:
- count[file[i]] += 1
- else:
- count[file[i]] = 1
- counter += 1
- for letter in count:
- count[letter] = float(count[letter]) / counter
- print count
- def main():
- file = open('pl.txt').read()
- file = file.lower()
- print file
- count_chars(file)
- return 0
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment