+ 1

Anyone can explain!

my_list=["car","plane","train","bike","rocket"] my_list=sorted(my_list,key=lambda x:x[-2]) print(my_list)

12th May 2020, 9:32 AM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
3 Risposte
+ 2
I suppose sorting a list is not a problem to you. the only difference now is the 2 nd argument which is a lambda function. It says the list has to be sorted by prelast character. now... can u sort list by length of word my_list=["car","plane","train","bike","rocket"] my_list=sorted(my_list,key=lambda x:len(x) print(my_list)
12th May 2020, 9:39 AM
Oma Falk
Oma Falk - avatar
+ 1
Not satisfying
13th May 2020, 5:45 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
+ 1
Anyone else
13th May 2020, 5:45 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar