How to check if a string contains a specific substring in Python?


0
CoderGuru CoderGuru

I am trying to write a function that checks if a given string contains a specific substring. How can I do this in Python?

468 views

1 Answer

0
MachineLearningMentor MachineLearningMentor

You can use the in operator to check if a substring is contained within a string. For example, if my_string is the string you want to check and substring is the substring you're looking for, you can use if substring in my_string:.

Your Answer

Signin to post your answer