I want this program to read a text file then target and replace anything start with < and end with >
for example it finds <html>, replace that into ****
but somehow i tested it and it didn't work than i expected. any suggestions?
def remove_html(text):
txtLIST = list(text)
i = 0
while i < len(txtLIST):
if txtLIST[i] == '<':
while txtLIST[i] != '>':
txtLIST.pop(i)
txtLIST.pop(i)
else:
i = i + 1
replace = 4*'*'
return replace.join(txtLIST)
file = open('remHTML.txt','r')
test = file
display = remove_html(test)
print display