2021年1月21日星期四

How to convert a two nested list of lists into a nested list of tuples in Python?

I am trying to convert a two nested list of lists into a nested list of tuples in Python. But I cant get the desired result. The input looks like:

first_list = [['best', 'show', 'ever', '!'],                ['its', 'a', 'great', 'action','movie']]    second_list = [['O', 'B_A', 'O', 'O'],                 ['O', 'O', 'O', 'B_A','I_A']]  

The desired output should look like:

result = [[('best','O'),('show','B_A'),('ever','O'),('!','O')],            [('its','O'),('a','O'),('great','O'),('action','B_A'),('movie','I_A')]]  

Thank you in advance!

https://stackoverflow.com/questions/65838307/how-to-convert-a-two-nested-list-of-lists-into-a-nested-list-of-tuples-in-python January 22, 2021 at 09:53AM

没有评论:

发表评论