+ 1
Anyone can explain!
my_list=["car","plane","train","bike","rocket"] my_list=sorted(my_list,key=lambda x:x[-2]) print(my_list)
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)
+ 1
Not satisfying
+ 1
Anyone else