Computer Science, asked by lokesh2092, 11 months ago

write a program to count number of occurrence of a given charcter in string

Answers

Answered by susmita1234
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

susmita1234: Please mark me brainilist
lokesh2092: ok
Answered by viji18net
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