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
Answers:
You can use rfind
:
>>> "abcd}def}".rfind('}')
8
How would I find the last occurrence of a character in a string?
string = "abcd}def}"
string = string.find('}',last) # Want something like this
You can use rfind
:
>>> "abcd}def}".rfind('}')
8