I've a list like:
mylist = ['La', 'domestication', "d'un", 'animal', 'ou', "d'un", 'végétal,', 'necessite', "l'acquisition", "d'une", 'ferme']
I want to split elements which have " ' " inside by 2 elements and keep their index in the original list.
OUTPUT REQUESTED : my_new_list = ['La', 'domestication', "d'" ,'un', 'animal', 'ou', "d'", 'un', 'végétal,', 'necessite', "l'", 'acquisition', "d'", 'une', 'ferme']
I've tried few thing but I admit I'm stuck to replace the two new split element in the correct index, here is the code I've tried:
for word in mylist:
if "'" in word:
new_words = word.split("'")
mylist[mylist.index(word)] = (new_words[0]+"'")
mylist.insert(mylist.index((new_words[0]+"'")+1), new_words[1])
print(mylist)
Thank you for your time and help :)