1sample_str = 'Sample String'
2# Get last character of string i.e. char at index position -1
3last_char = sample_str[-1]
4
5print('Last character : ', last_char)
6# Output
7Last charater : g
1a = '123456789'
2
3#to get last char, acess index -1
4print(a[-1])
5
6#this works the same as:
7print(a[len(a)-1])
8
9#instead of 1, subtract n to get string's nth char from last
10#let n = 4
11print(a[-4])
12
13#result:
149
159
166
17