0

How can I make the code return the last letter of each word in a list in python.

Example_list = [ ‘ the ‘ , ‘ cat, ‘ ran ‘ , ‘ across’ , ‘ the ‘ , ‘street’, ‘ to ‘ , ‘catch ‘ , ‘ the ‘ , ‘ mouse’]

8th May 2022, 4:17 PM
Mingo_24
2 Answers
+ 1
Make use of indexing, -1 refers to the last characterof the string: "word"[-1]
8th May 2022, 4:19 PM
Lisa
Lisa - avatar
+ 1
Example_list = [ ‘ the ‘ , ‘ cat, ‘ ran ‘ , ‘ across’ , ‘ the ‘ , ‘street’, ‘ to ‘ , ‘catch ‘ , ‘ the ‘ , ‘ mouse’] Last_char_list=[w[-1] for w in Example_list] print(last_char_list)
9th May 2022, 7:27 AM
Pavan Barve
Pavan Barve - avatar