0

this is example what i'm looking for.

Example:

Input: ['234','34','22','7','99'] 

0:0
1:0
2:3
3:2
4:2
5:0
6:0
7:1
8:0
9:2
Andy
  • 49,085
  • 60
  • 166
  • 233
SSR.P.S.das
  • 375
  • 1
  • 3
  • 14

1 Answers1

1

joined joins all the chars into one string "2343422799" Then we loop through the digits 0-9 and use the count method to see how many times each digit appears in the string and print the digit and the count using string formatting.

 l=['234','34','22','7','99']     
joined="".join(l) # joins all the chars into one string "2343422799"
for ch in range(10): # go through digits from 0-9
    print "{}:{}".format(ch,joined.count(str(ch))) 
0:0
1:0
2:3
3:2
4:2
5:0
6:0
7:1
8:0
9:2
Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321