You can use a list-comprehension with the standard scheme for flattening arrays:
lst = ['Agrigento',
' Tal Andar, Regie Curie',
' Landar ta il Geuenie',
' Landar ta il Guedi, Casali Bisibud',
'Aragonia',
'Athene']
lst = [x for y in lst for x in y.split(',')]
print(lst) # -> ['Agrigento', ' Tal Andar', ' Regie Curie', ' Landar ta il Geuenie', ' Landar ta il Guedi', ' Casali Bisibud', 'Aragonia', 'Athene']
Note: We are taking advantage of the fact that splitting a string that does not contain the character used as a delimiter returns the same string in a list:
>> 'a'.split('b')
['a']
As a result, the flattening meets no obstacles. For more info, see split
.
Finally, as @tobias says, if you want to get rid of the spaces in the front and back of the names, you can use the strip()
method. Simply modify the above comprehension to the one given below.
lst = [x.strip() for y in lst for x in y.split(',')]
print(lst) # -> ['Agrigento', 'Tal Andar', 'Regie Curie', 'Landar ta il Geuenie', 'Landar ta il Guedi', 'Casali Bisibud', 'Aragonia', 'Athene']