Ask 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 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. 2 April, 07:18
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers