Given two strings, check if s1 is there in s2.
Input : s1 = geeks s2=geeks for geeks Output : yes Input : s1 = geek s2=geeks for geeks Output : yes
We can iteratively check for every word, but Python provides us a inbuilt function find() which checks if a substring is present in the string, which is done in one line.
find() function returns -1 if it is not found, else it returns first occurrence, so using this function this problem can be solved.
- Python | Check if substring present in string
- Number of Positions to partition the string such that atleast m characters with same frequency are present in each substring
- Check whether the Average Character of the String is present or not
- Queries to check if string B exists as substring in string A
- Check if a string is substring of another
- Python | Check if element is present in tuple
- Check if string can be rearranged so that every Odd length Substring is Palindrome
- Python | Check if element is present in tuple of tuples
- Check if string can be made lexicographically smaller by reversing any substring
- Python | Frequency of substring in given string
- Python | Remove the given substring from end of string
- Python | All occurrences of substring in string
- Python | Get the string after occurrence of given substring
- Python | Check if substring is part of List of Strings
- Python | Get the substring from given string using list slicing
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.