Ask Question
19 May, 04:48

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. 19 May, 06:46
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers