Write a Python Program to Count Occurrence of a Character in a String with a practical example. This python program allows you to enter a string and a character.
# Python Program to Count Occurrence of a Character in a String 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)
No comments:
Post a Comment