sample_str = 'Sample String'
# Get last character of string i.e. char at index position -1
last_char = sample_str[-1]
print('Last character : ', last_char)
# Output
Last charater : g
last_n_chars = -4
mystr = "abcdefghijkl"
mystr[last_n_chars:]
# 'ijkl'
s='Hello world'
s.rfind('l')
# Where in the text is the last occurrence of the string "casa"?
txt = "Mi casa, su casa."
x = txt.rfind("casa")
print(x)
original_string = "sentence one. sentence two. sentence three"
last_char_index = original_string.rfind(".")
new_string = original_string[:last_char_index] + "," + original_string
print(new_string)
"sentence one. sententce two, sentence three"