About 494,000 results
Open links in new tab
  1. Python String find() Method - W3Schools

    The find() method finds the first occurrence of the specified value. The find() method returns -1 if the value is not found. The find() method is almost the same as the index() method, the only difference is that the index() method raises an exception if the …

  2. How to Use the find() Function in Python? - Python Guides

    Jan 8, 2025 · Learn how to use Python's `find()` function to locate substrings within a string. This tutorial covers syntax, examples, and tips for efficient string searching.

  3. Python String find() Method - GeeksforGeeks

    Oct 27, 2024 · The find() method in Python returns the index of the first occurrence of a substring within a given string. If the substring is not found, it returns -1. This method is case-sensitive, which means “ abc ” is treated differently from “ ABC “. Syntax of find() Method. s.find(substring, start, end)) Parameter:

  4. Difference Between find() and index() in Python - GeeksforGeeks

    Nov 21, 2024 · Use find () when we need to check if a substring exists and do not want to handle exceptions. Use index () when we are sure that the substring exists or we want an exception to be raised if it doesn’t exist.

  5. Python String find() Method with Examples

    Jan 24, 2024 · The find() method in Python is a built-in string method used to locate the index of the first occurrence of a specified substring within a string. It returns the index of the first character of the first occurrence of the substring, or -1 if the substring is not found.

  6. Python find() – How to Search for a Substring in a String

    Jul 25, 2022 · In this article, you will learn how to use Python's built-in find() string method to help you search for a substring inside a string. Here is what we will cover: Syntax of the find() method. How to use find() with no start and end parameters example; How to use find() with start and end parameters example; Substring not found example

  7. Python String Methods Tutorial – How to Use find() and …

    Sep 1, 2021 · How to Use find() to Search for Patterns in Python Strings. You can use Python's find() method to search through a string for a pattern. The general syntax is shown below. <this_string>.find(< this_pattern >) The input string that we'd like to search through is denoted by the placeholder this_string.

  8. String find() in Python - Python Tutorial

    Just call the method on the string object to search for a string, like so: obj.find (“search”). The find () method searches for a query string and returns the character position if found. If the string is not found, it returns -1. In simple English: find out if a string contains another string. The find method returns the index if a word is found.

  9. find() in Python - String Methods with Examples - Dive Into Python

    The find() method in Python is a string method that returns the lowest index within the string where a specified substring is found. If the substring is not found, it returns -1.

  10. Python string find() Method | CodeToFun

    Nov 22, 2024 · In this tutorial, we'll explore the usage and functionality of the find() method in Python. The syntax for the find() method is as follows: string: The string in which the search will be performed. substring: The substring that you want to find within the string. start (Optional): The starting index for the search.

Refresh