Почему выдаёт ошибку list.remove(x): x not in list?
Наипростейший код
adms = []
with open("ADM.txt", "r") as file:
for line in file:
adms.append(line[:-1])
adms.remove("1617")
file = open("ADM.txt", "w")
for admID in adms:
file.write(f"{admID} \n")
file.close()
adms = []
with open("ADM.txt", "r") as file:
for line in file:
adms.append(line.strip())
adms.remove("1011")
file = open("ADM.txt", "w")
for admID in adms:
file.write(f"{admID} \n")
file.close()
надо было поменять на 4 строчке кода line[:-1] на line.strip() и всё заработало
adms = []
with open("ADM.txt", "r") as file:
for line in file:
adms.append(line[:-1])
for space in adms:
adms.append(space.strip())
break
adms.remove("1415")
file = open("ADM.txt", "w")
for admID in adms:
file.write(f"{admID} \n")
file.close()