Skip to content Skip to sidebar Skip to footer

Find Last Occurrence Of Character In String Python

How would I find the last occurrence of a character in a string? string = 'abcd}def}' string = string.find('}',last) # Want something like this

Solution 1:

You can use rfind:

>>> "abcd}def}".rfind('}')
8

Post a Comment for "Find Last Occurrence Of Character In String Python"