how do I split this list
['charmander|4/16/2022 18:5:52|Good to see you!', 'charmander|4/16/2022 18:6:0|Good to see you!']
to
['charmander', '4/16/2022 18:5:52', 'Good to see you!' , 'charmander', '4/16/2022 18:5:52', 'Good to see you!']
by the way, this list is part of a txt file and has been split already by doing this
file = open('messages/' + username + '.txt', 'r')
data = file.read().strip()
results = data.split("\n")
>Solution :
You can do it like this using string.split("|")
l = ['charmander|4/16/2022 18:5:52|Good to see you!', 'charmander|4/16/2022 18:6:0|Good to see you!']
newList = []
for val in l:
newList += (val.split("|"))
Output:
['charmander',
'4/16/2022 18:5:52',
'Good to see you!',
'charmander',
'4/16/2022 18:6:0',
'Good to see you!']