so my code is as follows:
promotion = [[""], ["promotion applied"],[""]]
how do I make it go from there to this state:
promotion = ["", "promotion applied", ""]
so my code is as follows:
promotion = [[""], ["promotion applied"],[""]]
how do I make it go from there to this state:
promotion = ["", "promotion applied", ""]
Using list comprehension:
>>> promotion = [[""], ["promotion applied"],[""]]
>>> [x[0] for x in promotion]
['', 'promotion applied', '']
with tuple unpacking:
>>> [x for x, in promotion] # works only if all items are single-item sequences.
['', 'promotion applied', '']