文字列入力からHTMLタグを削除するだけのコードをPythonで作成しようとしています。しかし、何らかの理由で、私のホーム Python インストールではコードが実行されず (ハングするだけ)、Udacity インターフェースで強制終了されます。
どこが間違っていますか?
def remove_tags(sentence):
list = []
state = 0
while state == 0:
location1 = sentence.find('<')
location2 = sentence.find('>',location1)
if location1 != -1:
chamber = sentence[location1:location2+1]
sentence.replace(chamber,'')
elif location1 == -1:
state = 1
return sentence.split()
return sentence.split()
print remove_tags('''<table cellpadding='3'>
<tr><td>Hello</td><td>World!</td></tr>
</table>''')