Home > database >  How to unpack list created by map(lambda) inside a tuple?
How to unpack list created by map(lambda) inside a tuple?

Time:12-20

I have a list of strings of which I want to have all the possible cased versions of a few string (e.g. 'yes' -> 'yes', 'Yes', 'YES', etc.). I'm using a map(lambda) construction, but I can't get the strings that are returned to be **not ** in a nested list like that. How do I do this?

>> (
some_other_objects,
*list((map(lambda s: list(map(''.join, itertools.product(*zip(s.upper(), s.lower())))), ['no', 'maybe'])))
)

# actual result:
(
some_other_objects,
['no', 'No', 'NO', 'nO', ...],
['Maybe', 'maybe', 'MAYBE', ...]
)

# desired result:
(
some_other_objects,
'no', 'No', 'NO', 'nO', ..., 
'Maybe', 'maybe', 'MAYBE', ...
)

Thank you in advance!!

  • Related