Ask Question
9 August, 19:41

write a python function that takes string j and returns a dictionary showing number of letters and digits in j. The returned dictionary is supposed to have two keys digits and letters. you can take advantage of isdigit () and isalpha () which are methods for string objects showing if a string is digit

+5
Answers (1)
  1. 9 August, 20:52
    0
    def letterDigitCount (j):

    dic={"digits":0,"letters":0}

    for a in j:

    if a. isdigit ():

    dic["digits"]+=1

    elif a. isalpha ():

    dic["letters"]+=1

    return dic
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “write a python function that takes string j and returns a dictionary showing number of letters and digits in j. The returned dictionary is ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers