Hey everyone I was trying to figure out a way to change a string like this (in python3)
"<word>word</word>"
into three strings
"<word>" "word" "</word>"
that I'm going to put in a list.
At first I tried the strip() command, but it only strips the beginning and the end of the string. Then I tried a more complicated method of reading through the text one letter at a time, building the word, and adding a " " after any ">" using an IF statement but I couldn't figure out how to add a space before the other "<".
Is their a simple way to split these words up?
Edit: This isn't all my data, I am reading in an xml file and using a stack class to make sure that the file is balanced.
<word1></word1> <word2>worda</word2> <word3>wordb</word3> <word4></word4>...
Edit2: Thanks for all the answers everyone! I would vote up all your answers if I could. For practical use the xml parser did work fine but for what I needed the regex command worked perfectly. Thank You!
xmlmodule.