How to count the occurrence of a given character in a String?
How to count the occurrence of a given character in a String?
https://javarevisited.blogspot.com/2011/06/top-programming-interview-questions.html
CODE:
a = input('Enter a string: ')
b = input('Which char need to find occurence: ')
count = 0
for i in a:
if b == i:
count += 1
print(b,'character',count,'times occured in given string')
-----
By
PyKAR
https://javarevisited.blogspot.com/2011/06/top-programming-interview-questions.html
CODE:
a = input('Enter a string: ')
b = input('Which char need to find occurence: ')
count = 0
for i in a:
if b == i:
count += 1
print(b,'character',count,'times occured in given string')
-----
By
PyKAR
Comments
Post a Comment