This question already has an answer here:
Given a string of printable ASCII, output the frequency of each character in that string.
- Input is given as a string of printable ASCII characters (decimal
- Output the frequency of each character, in ASCII order.
- The output must have a format similar to
[character][separator][count]. Provided that there is a single, non-newline separating string between the character and its frequency, it is a valid output.
- Output can be a single string, multiple strings, list of 2-tuples, array of tuples, etc.
- Input and output can be given using any convenient method.
- Standard loopholes are forbidden.
- This is code-golf, so shortest in bytes wins.
abcd //outputs a: 1 b: 1 c: 1 d: 1
Over 9001! //outputs [ 1 ! [ 1 0 [ 2 1 [ 1 9 [ 1 O [ 1 e [ 1 r [ 1 v [ 1
--<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+. //outputs (as 2-tuples) (+,14),(-,13),(.,13),(<,21),(>,13),([,2),(],2)
Su3OH39IguWH //outputs (as 2d array) [[3,2],[9,1],[H,2],[I,1],[O,1],[S,1],[W,1],[g,1],[u,2]]