To check if a string contains a given substring in Python, you can use the 'in' operator.
In this example,
def containsSubstring(str, substr):
return substr in str
str = 'Hello World'
substr = 'World'
contains = containsSubstring(str, substr)
print(f'String contains substring {substr}: {contains}')
String contains substring World: True
In this tutorial, we learned How to Check if a String contains given Substring in Python language with well detailed examples.