I want to convert this list
list = ['orange','cherry,strawberry','cucumber,tomato,coconut,avocado','apple','blueberry,banana']
to
new_list = ['orange','cherry','strawberry','cucumber','tomato','coconut','avocado','apple','blueberry','banana']
Is it possible to do that? Please help me!
Join and split!
>>> lst = ['orange','cherry,strawberry','cucumber,tomato,coconut,avocado','apple','blueberry,banana']
>>> ','.join(lst).split(',')
['orange', 'cherry', 'strawberry', 'cucumber', 'tomato', 'coconut', 'avocado', 'apple', 'blueberry', 'banana']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With