Find Substring in String

Advanced

Find Substring in String

Let's go exploring in the world of strings! Your challenge is to find if a small string (which we call a "substring") exists within a bigger string.

Imagine you're looking for a specific word in a sentence or a specific tune in a song. Detecting a substring in a string is quite similar!

Your Task

Write a function find_substring that takes in two arguments:

  • main_string: the large string that you want to search within.
  • sub_string: the small string you are looking for.

Your function should return True if the sub_string is found in the main_string and False otherwise.

Examples

find_substring("hello world", "world") # should return True find_substring("hello world", "planet") # should return False find_substring("banana", "ana") # should return True find_substring("banana", "baa") # should return False

This is a fun way to start understanding how to manipulate and search through text using Python. Good luck exploring those strings!

Geek
Inputs

Arg 1:

"hello world"

Arg 2:

"world"
Expected Output
true
Actual Output
Find Substring in String [advanced] | Coding for Kids