Check If Backslash In String In Python
In this tutorial I will show you how to check if a backslash(\) is there in a string in python, to check whether there is a backslash in a string we will use if statement and check if there is a backslash in the string so let’s see it in code.
Program To Check If Backslash In String In Python
text = "hi \ how are you" if '\\' in text: print("there is a backlash")
Above is the program to check if backslash in string in python, we used if statement to check if there is any backslash in the string text.
After running this program you will see that it printed that there is a backslash in the string. As you can see in the program we used two backslash to check because if we used one backslash to check it will give us error.
Here are some more python program tutorials for you:
- Python Program To Check If A Variable Is A Function.
- Python Program To Check If A Variable Is A Dictionary.
- Python Program To Check Even Or Odd Numbers.
- Python Program To Check Composite Numbers.
- Python Program To Check Whether A Person Is Senior Citizen Or Not.
- Python Program To Check Whether A Person Is Eligible To Vote Or Not.
I hope you found what you were looking for from this tutorial, and if you want more python programs and tutorials like this, do join our Telegram channel for future updates.
Thanks for reading, have a nice day 🙂