Write a program to count the number of times a character appears in a given string.
Answers
Answered by
7
Answer:
str = input("Enter the string: ")
ch = input("Enter the character to count: ");
c = str.count(ch)
print(ch, "occurs", c, "times")
Explanation:
Enter the string:
Enter the character to count: e
e occurs 2 times
Similar questions