带有2个字符串的列表中的Python列表

I have 2 lists of strings. I would like to combine them together to create list in lists like this one below. [['Hello','praet:sg:m1:perf'], ['world', 'subst:pl:acc:n']] How to do it? Somehow create instance of list in list or there is some "python magic"?

谢谢

评论
zfugit
zfugit

zip (Python Docs) is what you are looking for. You can stitch together two list in a list comprehension:

l1 = [1, 2, 3]
l2 = ['a', 'b', 'c']
zipped = [[item1, item2] for (item1, item2) in zip(l1,l2)]
点赞
评论