{"id":4661,"date":"2021-04-29T12:24:17","date_gmt":"2021-04-29T06:54:17","guid":{"rendered":"https:\/\/python-programs.com\/?p=4661"},"modified":"2021-11-22T18:42:59","modified_gmt":"2021-11-22T13:12:59","slug":"python-check-if-a-string-contains-a-sub-string-case-insensitive","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-check-if-a-string-contains-a-sub-string-case-insensitive\/","title":{"rendered":"Python : Check if a String contains a Sub String | Case Insensitive"},"content":{"rendered":"

Strings are one of the most commonly used types in Python. We can easily make them by enclosing characters in quotes. Python considers single quotes to be the same as double quotes. String creation is as easy as assigning a value to a variable.<\/p>\n

Let’s look at different ways to solve the general problem of determining whether a specific piece of string is present in a larger string. This is a very common type of problem that every programmer encounters at least once in his or her career. This article discusses various methods for resolving it.<\/p>\n

Given a string and substring ,the task is to check if the substring is present in given string.<\/p>\n

Examples:<\/strong><\/p>\n

1)Case sensitive<\/strong><\/p>\n

Input:<\/strong><\/p>\n

string = 'This is BTechGeeks online platform'\u00a0 substring = 'online'<\/pre>\n

Output:<\/strong><\/p>\n

Yes<\/pre>\n

2)Case insensitive<\/strong><\/p>\n

Input:<\/strong><\/p>\n

string = 'This is BTechGeeks Online platform'\u00a0 substring = 'online'<\/pre>\n

Output:<\/strong><\/p>\n

Yes<\/pre>\n

Determine whether a String contains a Sub String<\/h2>\n

There are several ways to check whether a string contains given substring some of them are:<\/p>\n