Use .rfind()
:
>>> s="hello"
>>> s.rfind('l')
3
Also don’t use str
as variable name or you’ll shadow the built-in str()
.
More Related Contents:
- How t extract last part of a text in python [duplicate]
- Convert bytes to a string
- How do I lowercase a string in Python?
- Filter pandas DataFrame by substring criteria
- Why do backslashes appear twice?
- Changing one character in a string
- Random string generation with upper case letters and digits
- Converting a string representation of a list into an actual list object [duplicate]
- How to split the definition of a long string over multiple lines?
- using backslash in python (not to escape)
- Find and replace string values in list
- Pandas Extract Number from String
- Python convert tuple to string
- Find substring in string but only if whole words?
- Python split string into multiple string [duplicate]
- Find all upper, lower and mixed case combinations of a string
- How does my input not equal the answer?
- Finding occurrences of a word in a string in python 3
- Having both single and double quotation in a Python string
- shuffle string in python
- Count number of words per row
- Why can’t I end a raw string with a backslash? [duplicate]
- Why empty string is on every string? [duplicate]
- Is there a native templating system for plain text files in Python?
- Convert a columns of string to list in pandas
- What’s the difference between str.isdigit(), isnumeric() and isdecimal() in Python?
- Python: is using “..%(var)s..” % locals() a good practice?
- How does python startswith work?
- How can I match an exact word in a string?
- What does “table” in the string.translate function mean?