Count the Letters and Digits

Published by sabonchi in

Write a function that takes a string and calculates the number of letters and digits within it. Return the result as anonymous type in string format.

Examples

count_all("Hello World") ➞ "{ LETTERS =  10, DIGITS =  0 }"

count_all("H3ll0 Wor1d") ➞ "{ LETTERS =  7, DIGITS =  3 }"

count_all("149990") ➞ "{ LETTERS =  0, DIGITS = 6 }"

Notes

  • Tests contain only alphanumeric characters.
  • Spaces are not letters.
  • All tests contain valid strings.
  • Return the result as anonymous type.
Watch a quick demo on how Edabit works.