我想查找和比较有效的列表中的字符串元素,然后删除其是其他字符串元素的部件列表(具有相同的起点)
list1 = [ 'a boy ran' , 'green apples are worse' , 'a boy ran towards the mill' , ' this is another sentence ' , 'a boy ran towards the mill and fell',.....]
Run Code Online (Sandbox Code Playgroud)
我打算得到一个如下所示的列表:
list2 = [ 'green apples are worse' , ' this is another sentence ' , 'a boy ran towards the mill and fell',.....]
Run Code Online (Sandbox Code Playgroud)
换句话说,我想从那些以相同的第一个字符开头的元素中保留最长的字符串元素。