String practice 1


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C, C++, Python3

This practice problem will require you to programme basic string operations.

If you are using C++, it is recommended that you use C++ string but C styled Char Array is also fine. If you are using Python, please keep reading.

Your task is to compare 2 strings, and figure out if the second string is a substring of the first.

Input Specification

The first line will contain an integer \(N\) (\(1 < N < 200\)), indicating the number of cases.

The following \(N\) lines will each contain 2 strings separated by whitespace. These 2 strings will not contain whitespace internally. Each string will not be longer than 200 characters.

Output Specification

The output should contain \(N\) lines, each line either Yes or No, indicating whether the second string is a substring of the first.

Sample Input

2
Hello world!
HelloWorld! Hello

Sample Output

No
Yes

Comments


  • 0
    jetic  commented on Sept. 22, 2021, 5:33 p.m.

    In Python, if you have 2 string str1 and str2, and you want to know if str2 is a substring of str1, you can simply use the expression

    if str2 in str1:
        print("Is substring")
    else:
        print("Not substring")

    The expression str2 in str1 will return to you a bool value of either True or False