I have a list like the following:
my_list = ['google', 'microsoft,facebook']
and I need to convert this into:
my_list = ['google', 'microsoft', 'facebook']
I tried doing it this way:
new_list = [item.split(',') for item in my_list]
flat_list = [item for sublist in new_list for item in sublist]
but this method involves unnecessary additional variables and multiple for loops. Is there a way we can make this easier?