File tree 2 files changed +37
-0
lines changed
CountMillionCharacters-Variations
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ """Get the number of each character in any given text.
2
+
3
+ Inputs:
4
+ A txt file -- You will be asked for an input file. Simply input the name
5
+ of the txt file in which you have the desired text.
6
+
7
+ """
8
+
9
+ import pprint
10
+ import collections
11
+
12
+
13
+ def main ():
14
+
15
+ file_input = input ('File Name: ' )
16
+
17
+ with open (file_input , 'r' ) as info :
18
+ count = collections .Counter (info .read ().upper ())
19
+
20
+ value = pprint .pformat (count )
21
+ print (value )
22
+
23
+ if __name__ == "__main__" :
24
+ main ()
Original file line number Diff line number Diff line change
1
+ import pprint
2
+
3
+ inputFile = input ('File Name: ' )
4
+
5
+ count = { }
6
+ with open (inputFile , 'r' ) as info :
7
+ readFile = info .read ()
8
+ for character in readFile .upper ():
9
+ count .setdefault (character , 0 )
10
+ count [character ] = count [character ]+ 1
11
+
12
+ value = pprint .pformat (count )
13
+ print (value )
You can’t perform that action at this time.
0 commit comments