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â]
2 Antworten
+ 1
Make use of indexing, -1 refers to the last characterof the string:
"word"[-1]
+ 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)