Im trying to create a function which reads each line in a file and compares the words with their reverse (palindrome) version
i.e > (heheh = heheh) & (law = wal)
lst = 
with open("words.txt", "r") as f:
for line in f:
if line == line[::-1]:
When iterating over the lines in a file, you're getting the line-terminator along with the rest of the line. Id est, you're not comparing
"eye" == "eye", but
"eye\n" == "\neye", which is of course false for all words.
line = line.strip() before the comparison.