In this Python Program, we will learn how to find all the occurrences of a specific character in a given string.
Here is the source code of the program to find all the occurrences of a specific character in a given string.
In this program, we use the for
loop to iterate each character in a string and use the if
statement inside the loop to match with the given character in a string.
Python Program to find All the Occurrence of a Character in a Given String Using For Loop
Enter the String: Python Program to find All the Occurrence of a Character in a Given String
Enter The Character To Find All the Occurrence: a
a is Found at Position 13
a is Found at Position 24
a is Found at Position 46
a is Found at Position 50
a is Found at Position 52
a is Found at Position 61
In this program, we use the While
loop to iterate each character in a string and use the if
statement inside the loop to match with the given character in a string.
Enter the String: Python Program to find All the Occurrence of a Character in a Given String
Enter The Character To Find All the Occurrence: i
i is Found at Position 20
i is Found at Position 58
i is Found at Position 64
i is Found at Position 72
Comments