There is a list containing the "Tolkien book"s, and another containing the "Lord of the rings" books.
Some of the books in the "Lord of the rings" books are the same as in the "Tolkien books".
I want to use a for loop to check for which books in the "Tolkien" books are the same as the ones in the "Lord of the rings" books. And if the for loop finds a match, it will change the item in the Tolkien list to "LOTR book: {Tolkien book}"
My issue is: The for loop dosent change the items in the Tolkien list. I know that it rechongnizes the matches, but it dosent change the list. Why is that?
Lord_Of_The_Rings = ["The Hobbit", "The Fellowship of the Ring", "The Two Towers", \
"The Return of the King"]
Tolkien_books = ["The Hobbit", "Farmer Giles of Ham", "The Fellowship of the Ring", \
"The Two Towers", "The Return of the King", "The Adventures of Tom Bombadil", "Tree and Leaf"]
for T_book in Tolkien_books:
for LOTR_book in Lord_Of_The_Rings:
if LOTR_book == T_book:
T_book = f"LOTR: {T_book}"
print(Tolkien_books)