>>> fruit = 'banana'
>>> length = len(fruit)
>>> last = fruit[length-1]
Alternatively, we can use negative indices, which count backward from the end of the string. The expression fruit[-1] yields the last letter, fruit[-2] yields the second to last, and so on.
Tuesday, October 12
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment