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
  • 46,308
  • 56
  • 161
  • 219
SSR.P.S.das
  • 335
  • 1
  • 3
  • 13

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
  • 168,988
  • 22
  • 228
  • 312