Write a Python program to count the number of occurrences of a specific character in a string.

Write a Python program to count the number of occurrences of a specific character in a string.

1
2
3
4
5
s = "The quick brown fox jumps over the lazy dog."  
print("Original string:")
print(s)
print("Number of occurrence of 'o' in the said string:")
print(s.count("o"))

Final output

Leave a Comment