79562474

Date: 2025-04-08 15:35:02
Score: 1
Natty:
Report link

Instead of doing list comprehension, you could use also lambda functions along side map:

>>> mylist = [[1,2,3], 7, [4,5,6], [7,8,9], 5]
>>> list(map(lambda item: item if isinstance(item, list) else \[item\], mylist))
[[1, 2, 3], [7], [4, 5, 6], [7, 8, 9], [5]]

Sorry for necroposting.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: vlopezb0