Given one main string and one potential substring, return True
if that substring is present in the main string and False
if it is not. It is case sensitive
Example:
common_substring("Panda", "and") -> returns True
common_substring("PANDA", "and") -> returns False
def common_substring(string, sub_str):
is_in = False
j = len(sub_str)
for i in range(0, len(string) - j + 1):
if string[i: i + j] == sub_str:
is_in = True
return is_in
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
# test.expect(boolean, [optional] message)
# test.assert_equals(actual, expected, [optional] message)
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
test.assert_equals(common_substring("Hello", "lo"), True)
test.assert_equals(common_substring("HELLO", "hello"), False)
test.assert_equals(common_substring("racecar", "car"), True)