About 402,000 results
Open links in new tab
  1. How to get the position of a character in Python? - Stack Overflow

    Feb 19, 2010 · 6 If you want to find the first match. Python has a in-built string method that does the work: index ().

  2. Examples for string find in Python - Stack Overflow

    Jul 7, 2013 · Python might in general prefer exceptions, but many users expect there to be a non-exception-raising-find-index method as well, especially as that's how it's done in almost every other …

  3. How to find all occurrences of a substring? - Stack Overflow

    Python has string.find() and string.rfind() to get the index of a substring in a string. I'm wondering whether there is something like string.find_all() which can return all found indexes (not only the first …

  4. python - How to get a string after a specific substring ... - Stack ...

    Jul 4, 2021 · my_string="hello python world , i'm a beginner" print(my_string.split("world",1)[1]) split takes the word (or character) to split on and optionally a limit to the number of splits. In this example, split …

  5. How do I get a substring of a string in Python? - Stack Overflow

    Aug 31, 2016 · As someone who began with Python instead of [dirty word]-languages like PHP, I think Python is much more simple and intuitive with its string [beginning:end]. Length generally isn't relevant.

  6. python - how to find whether a string is contained in another string ...

    str.find() and str.index() are nearly identical. the biggest difference is that when a string is not found, str.index() throws an error, like the one you got, while str.find() returns -1 as others' have posted. …

  7. How can I find the first occurrence of a sub-string in a python string ...

    Given the string "the dude is a cool dude", I'd like to find the first index of 'dude': mystring.findfirstindex('dude') # should return 4 What is the python command for this?

  8. python - string.find () aways evaluates to true - Stack Overflow

    May 21, 2025 · 10 find returns a number that's the position of the occurring string inside the search string. If it does not find it, it return -1. And every number that's not 0 in python evaluates to True. …

  9. What is the Python 3 equivalent of find ()? - Stack Overflow

    To use these functions, include the statement from string import * at the beginning of your file. This will allow you to use Python string functions. In particular, if you want to find the starting point of the first …

  10. Python string find() method - Stack Overflow

    Jul 19, 2017 · Python find (sub) method return the lowest index where the substring sub is found and return -1 if its not. In first piece of code, name.find ("Sac") returns "0", because index of "S" in Sachin …