InterviewSolution
Saved Bookmarks
| 1. |
Write a program for counting the number of every character of a given text file. |
|
Answer» The IDEA is to USE collections and pprint MODULE as shown below: import collectionsimport pprintwith OPEN("sample_file.txt", 'r') as DATA: count_data = collections.Counter(data.read().upper()) count_value = pprint.pformat(count_data)print(count_value) |
|