【发布时间】:2019-05-18 20:17:58
【问题描述】:
names=['alex','peter','sana','alice']
info=['alex is working on os_10 coolest one',
'peter is working on OS_9 which is not that cool',
'sana is working on OS_7 which is quite old',
'Thanos is also using os_10',
'alice is fan of thanos so she also uses os_10']
#我试过了
v=[]
for name in names:
a= [x for x in info if name in x]
#print(a)
v.append(a)
print(v)
首先我制作了一个列表,其中仅包含姓名在姓名列表中的那个人的信息 现在我想要像 alex: os_10, peter: OS_9 等这样的 o/p
【问题讨论】:
-
你试过什么?请发帖MCVE。
-
您要提取列表中句子的第一个和最后一个单词吗?规则是什么?
标签: python python-3.x python-2.7 spyder