flatMap or bind in Python 3?

后端 未结 1 1491
不知归路
不知归路 2021-01-12 19:46

Python provides list comprehensions that provide map/filter type functionality. Can I do a flatMap aka bind operation with this? I\'ve seen solutions with itertools or other

相关标签:
1条回答
  • 2021-01-12 20:20
    [y for x in [1, 2, 3] for y in [x, 10*x]]
    

    Just add another for to the list comprehension.

    0 讨论(0)
提交回复
热议问题