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')
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')