I am trying to write a program that orders a list of strings based on the last character in the item.
[\"Tiger 6\", \"Shark 4\", \"Cyborg 8\"]
are how my li
If the numbers are not single digits, you can try -
>>> l = ["Tiger 6", "Shark 4", "Cyborg 8", "Temporary 12"]
>>> l.sort(key = lambda x: int(x.rsplit(' ',1)[1]))
>>> l
['Shark 4', 'Tiger 6', 'Cyborg 8', 'Temporary 12']
str.rsplit(s, n)
function starts splitting the string at the end towards start of the string and stops after n splits. In the above case, it only splits the string once, at a space.