Mapping a nested list with List Comprehension in Python?

前端 未结 5 543
自闭症患者
自闭症患者 2020-12-11 03:28

I have the following code which I use to map a nested list in Python to produce a list with the same structure.

>>> nested_list = [[\'Hello\', \'Wo         


        
5条回答
  •  清歌不尽
    2020-12-11 03:52

    Map is certainly a much cleaner way of doing what you want. You can nest the list comprehensions though, maybe that's what you're after?

    [[ix.upper() for ix in x] for x in nested_list]
    

提交回复
热议问题