我有2 lists
strings
:
list1 = ['GERMANY','FRANCE','SPAIN','PORTUAL','UK']
list2 = ['ERMANY','FRANCE','SPAN','PORTUGAL','K']
我想获得一个list
,其中只显示少于1个字符的相应strings
。即:
final_list = ['ERMANY','SPAN','K']
最好的方法是什么?使用正则表达式?
由于
答案 0 :(得分:0)
你可以试试这个:
list1 = ['GERMANY','FRANCE','SPAIN','PORTUGAL','UK']
list2 = ['ERMANY','FRANCE','SPAN','PORTUGAL','K']
new = [a for a, b in zip(list2, list1) if len(a) < len(b)]