Counting Characters

Character Count Example

----- Unique Characters ----- File : constitution.txt Lines : 447 Characters: 44268 [ 1] (E) = 5049 11.406% [ 2] (T) = 3741 8.451% [ 3] (O) = 2676 6.045% [ 4] (S) = 2665 6.020% [ 5] (A) = 2594 5.860% [ 6] (N) = 2564 5.792% [ 7] (I) = 2405 5.433% [ 8] (R) = 2139 4.832% [ 9] (H) = 2006 4.531% [10] (L) = 1443 3.260% [11] (D) = 1200 2.711% [12] (C) = 1174 2.652% [13] (F) = 1009 2.279% [14] (U) = 835 1.886% [15] (P) = 757 1.710% [16] (M) = 695 1.570% [17] (B) = 595 1.344% [18] (Y) = 486 1.098% [19] (V) = 451 1.019% [20] (G) = 425 0.960% [21] (W) = 356 0.804% [22] (X) = 96 0.217% [23] (J) = 79 0.178% [24] (Q) = 46 0.104% [25] (K) = 46 0.104% [26] (1) = 30 0.068% [27] (Z) = 30 0.068% [28] (2) = 27 0.061% [29] (3) = 13 0.029% [30] (4) = 8 0.018% [31] (5) = 6 0.014% [32] (6) = 4 0.009% [33] (0) = 4 0.009% [34] (7) = 3 0.007% [35] (8) = 2 0.005% [36] (9) = 2 0.005% 11 unique characters not counted.

Coding Hints

When counting, are all 'A's the same, or are upper 'A' and lower 'a' counted separately.

## ---- [a-zA-Z0-9 .] only ##alphabet = 'abcdefghijklmnopqrstuvwxyz' +\ ## 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +\ ## '0123456789 .' ## ---- [a-zA-Z0-9] only ##alphabet = 'abcdefghijklmnopqrstuvwxyz' +\ ## 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +\ ## '0123456789' ## ---- [a-zA-Z] only ##alphabet = 'abcdefghijklmnopqrstuvwxyz' +\ ## 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # ---- [A-Z0-9] only alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +\ '0123456789' freq = {} if c in freq: freq[c] += 1 else: freq[c] = 1 for k,v in freq.items(): if k not in alphabet: continue