I'm having a problem managing my code and trying to figure out why I'm getting this error
books_title = open("books.txt", "a")
books = [books_title]
books_title.write("Narnia"+"\n")
books_title.write("Sagan om ringen"+"\n")
books_title.write("Snabba Cash"+"\n")
books_title.write("Star Wars"+"\n")
books_title.write("Harry Potter"+"\n")
books_title.close()
print("Böcker")
print("-"*5)
books_title = open("books.txt", "r")
print(books_title.read())
books_title.close()
books_title = open("books.txt", "w")
remove = input("Vilken bok vill du ta bort? ")
while remove not in books.split("\n"):
print("Boken du försöker ta bort finns inte")
remove = input("Vilken bok vill du ta bort? ")
for line in books.split("\n"):
if line != remove:
books_title.write(line + "\n")
print("Tar bort boken {}".format(remove))
print("-"*40)
txt_file.close()
Traceback (most recent call last): File "C:\Users\beaudouin11\Desktop\Python programmering\Fil och felhantering.py", line 18, in while remove not in books.split("\n"): AttributeError: 'list' object has no attribute 'split'