2
Question Question 2
Write a program to count the number of times a character appears in a given string.
Solution
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