Ask Question
6 February, 13:50

Count characters Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of times the character appears in the phrase. Ex: If the input is: n Monday

+3
Answers (1)
  1. 6 February, 17:14
    0
    str1=str (input ("Enter a character and phrase "))

    count = 0

    for i in range (0, len (str1)):

    if str1[0]==str1[i]:

    count+=1

    count1=count-1

    print (str1[0] + ' appears ' + 'this many times in ' + str1[1:] + ' is : ' + str (count1))
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Count characters Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of ...” 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