Skip to content
Fix Code Error

Does Python have a string ‘contains’ substring method?

March 13, 2021 by Code Error
Posted By: Anonymous

I’m looking for a string.contains or string.indexof method in Python.

I want to do:

if not somestring.contains("blah"):
   continue

Solution

You can use the in operator:

if "blah" not in somestring: 
    continue
Answered By: Anonymous

Related Articles

  • Use jQuery to scroll to the bottom of a div with lots of…
  • How to detect my browser version and operating system using…
  • What does this symbol mean in JavaScript?
  • Any quick way of updating a column based on timestamp
  • If I built an app with a CSS framework, and then they change…
  • Get protocol + host name from URL
  • Can't install via pip because of egg_info error
  • Regex on htaccess file gives INTERNAL REDIRECT error
  • Reference — What does this symbol mean in PHP?
  • I don't know why this python code for replacing all…

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?

Next Post:

Iterating over dictionaries using ‘for’ loops

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error