You can use Python in operator to check if a string contains a substring in Python. Here is a short example of how to check if a string contains a substring in Python –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
str = "hello world, welcome to cloudafafire" substr1 = "cloudafafire" substr2 = "CloudAffaire" if substr1 in str: print(True) else: print(False) ## Returns True if substr2 in str: print(True) else: print(False) ## Returns False |