write a program to count number of occurrence of a given charcter in string
Answers
Answered by
2
Given a string and a character, task is to make a function which count occurrence of the given character in the string.
Examples:
Input : str = "geeksforgeeks" c = 'e' Output : 4 'e' appears four times in str. Input : str = "abccdefgaa" c = 'a' Output : 3 'a' appears three times in str.
PLEASE PLEASE PLEASE MARK ME BRAINILIST
Examples:
Input : str = "geeksforgeeks" c = 'e' Output : 4 'e' appears four times in str. Input : str = "abccdefgaa" c = 'a' Output : 3 'a' appears three times in str.
PLEASE PLEASE PLEASE MARK ME BRAINILIST
susmita1234:
Please mark me brainilist
Answered by
0
Answer:
string = input("Please enter your own String : ")
char = input("Please enter your own Character : ")
count = 0
for i in range(len(string)):
if(string[i] == char):
count = count + 1
print("The total Number of Times ", char, " has Occurred = " , count)
Similar questions
Environmental Sciences,
6 months ago
Math,
6 months ago
Chemistry,
11 months ago
English,
11 months ago
Biology,
1 year ago