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

    Feb 19, 2010 · From the Python manual. string.find(s, sub[, start[, end]]) Return the lowest index in s where the substring sub is found such that sub is wholly contained in s[start:end]. Return …

  2. python - How can I find the index for a given item in a list? - Stack ...

    The returned index is computed relative to the beginning of the full sequence rather than the start argument. Caveats Linear time-complexity in list length. An index call checks every element of …

  3. python - How to find char in string and get all the indexes? - Stack ...

    Mar 25, 2019 · As the rule of thumb, NumPy arrays often outperform other solutions while working with POD, Plain Old Data. A string is an example of POD and a character too. To find all the …

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

    Aug 31, 2016 · @gimel: Actually, [:] on an immutable type doesn't make a copy at all. While mysequence[:] is mostly harmless when mysequence is an immutable type like str, tuple, …

  5. python - How to find all occurrences of a substring ... - Stack …

    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 …

  6. Remove char at specific index - python - Stack Overflow

    Jan 7, 2013 · I have a string that has two "0" (str) in it and I want to remove only the "0" (str) at index 4 I have tried calling .replace but obviously that removes all "0", and I cannot find a …

  7. How would I get everything before a : in a string Python

    Feb 14, 2019 · I have benchmarked these various technics under Python 3.9.13 (Jupyter Notebook). TLDR. When I know that c is in s, I would use partition for small strings and index …

  8. python - Find a substring in a string and returning the index of the ...

    Storing the index in place of just counting, can give us the distinct set of indices the sub-string gets repeated within the string. Disclaimer: I am 'extremly' new to Python programming. Share

  9. python - Replacing a character from a certain index - Stack Overflow

    As strings are immutable in Python, just create a new string which includes the value at the desired index. Assuming you have a string s , perhaps s = "mystring" You can quickly (and …

  10. python - Find index of last occurrence of a substring in a string ...

    Apr 5, 2020 · Python String rindex() Method. Description Python string method rindex() returns the last index where the substring str is found, or raises an exception if no such index exists, …

Refresh