I am trying to work out how to take a list of strings, and remove all of the letters in each string apart from the last two. Could someone please help? An example being ["Bob", "Steve", "Jeremy"], I only want the "ob", "ve", and "my". This has to work regardless of how long each string is. I only know how to do this with a specific sized string.
Asked
Active
Viewed 25 times
-1
-
Possible duplicate of [Is there a way to substring a string in Python?](http://stackoverflow.com/questions/663171/is-there-a-way-to-substring-a-string-in-python) – Manfred Radlwimmer May 17 '17 at 06:35
1 Answers
1
[i[-2:] for i in ["Bob", "Steve", "Jeremy"]]

jonrsharpe
- 115,751
- 26
- 228
- 437

Rob Gwynn-Jones
- 677
- 1
- 4
- 14