About 2,370,000 results
Open links in new tab
  1. Python String index() Method - W3Schools

    The index() method finds the first occurrence of the specified value. The index() method raises an exception if the value is not found. The index() method is almost the same as the find() …

  2. How to Index and Slice Strings in Python? - GeeksforGeeks

    Dec 31, 2024 · The index() method in Python is used to find the position of a specified substring within a given string. It is similar to the find() method but raises a ValueError if the substring is …

  3. string - How to get the position of a character in Python ... - Stack ...

    Feb 19, 2010 · There are two string methods for this, find() and index(). The difference between the two is what happens when the search string isn't found. find() returns -1 and index() raises …

  4. Find the Index of a Substring in Python - GeeksforGeeks

    Nov 19, 2024 · To get index of a substring within a Python string can be done using several methods such as str.find(), str.index(), and even regular expressions. Each approach has its …

  5. Python String index() - Programiz

    Python String index() The index() method returns the index of a substring inside the string (if found). If the substring is not found, it raises an exception .

  6. How To Index and Slice Strings in Python 3 - DigitalOcean

    Dec 15, 2021 · By referencing index numbers, we can isolate one of the characters in a string. We do this by putting the index numbers in square brackets. Let’s declare a string, print it, and call …

  7. Python String index(): Locating the Index of a Substring in a String

    In this tutorial, you'll learn how to use the Python string index() method to get the lowest index of a substring in a string.

  8. Python string.index() Method (With Examples)

    The index() method returns the index of the first occurence of a substring in the given string. It is same as the find () method except that if a substring is not found, then it raises an exception. …

  9. Access Characters in String by Index Python - PyTutorial

    Feb 7, 2025 · How to Access Characters by Index. To access a character in a string, use square brackets [] with the index inside. Here's an example: # Accessing characters by index …

  10. Python String Index: A Comprehensive Guide - CodeRivers

    Jan 24, 2025 · To access a single character in a string, you simply use the index within square brackets. For example: Slicing allows you to extract a substring from a string. The syntax for …

Refresh