In this program, we will take a string as input and remove all characters except the given character in a string.
Steps to solve the program
- Take a string as input.
- Remove all characters except the given character and add them to the list using list comprehension.
- Use for loop to iterate over each character of the string.
- Print the output.
Output :