Check Substring in String
Check Substring in String
Tags: String Manipulation Basics
Credit: CodingChallenge
Difficulty: Beginner
Type: Text
Category: Practice
Time Allowed: 5 s
Description:
Write a function that takes two strings and returns True
if the second string is a substring of the first string, or False
otherwise. This problem is designed to help you practice string searching
. The function should accept two parameters and return a boolean value.
Constraints:
- Both inputs will be
strings
. - The function should
return
aboolean
value:True
orFalse
.
Example:
- Input:
"hello world", "world"
- Output:
True
Test Case | Input | Expected Output |
---|---|---|
1 | ["hello world", "world"] | True |
2 | ["openai", "ai"] | True |
3 | ["python programming", "code"] | False |
4 | ["data science", "data"] | True |
5 | ["machine learning", "Machine"] | False |
6 | ["", "empty"] | False |
7 | ["substring", ""] | True |
8 | ["abcdef", "def"] | True |
9 | ["abcdef", "gh"] | False |
Leave a Comment
Please login to leave a comment.