Find last occurrence of character in string Python

Question:

How would I find the last occurrence of a character in a string?

string = "abcd}def}"
string = string.find('}',last) # Want something like this
Asked By: Apollo

||

Answers:

You can use rfind:

>>> "abcd}def}".rfind('}')
8
Answered By: Simeon Visser
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.