Пишет, чтоValueError: list.remove(x): x not in list
def remove_number(self, number):
try:
number = str(number).replace('\'','')
print("REMOVE THE Number " + number)
file = open('bot/test.xml', 'r')
tree = ET.parse(file)
root = tree.getroot()
elem = tree.find("numbers")
for child in elem:
print("Child")
print(child.text)
print(child.text + " " + str(number))
print(child.text.strip() == str(number).strip())
if child.text.strip() == str(number).strip():
root.remove(child)
print("Success")
tree.write('bot/test.xml')
return
except FileNotFoundError:
print("File not found")
.........
<root>
...
<numbers>
<number>79043358876</number>
<number>79043360876</number>
<number>79043363501</number>
<number>79043371799</number>
<number>79043370024</number>
<number>79043368917</number>
<number>79043360041</number>
<number>79043370209</number>
</numbers>
</root>