KnowledgeBoat Logo
|

Computer Science

Write a program to count the number of times a character appears in a given string.

Python

Python Dictionaries

10 Likes

Answer

str = input("Enter the string: ")
ch = input("Enter the character to count: ");
c = str.count(ch)

print("Count of character",ch,"in",str,"is :", c)

Output

Enter the string: appoggiatura
Enter the character to count: a
Count of character a in appoggiatura is : 3

Answered By

7 Likes


Related Questions