Python leaving behind "\" (PC vs Mac discrepancy)

61 views Asked by At

I'm new to Python, so any help would be appreciated.

I wrote the following code in a class on a PC, and it worked without any problems.

word = raw_input('Word: ')
f = open('dictionary.txt','r')
for line in f:
    line = line.strip()
    #print(line)
    if sorted(line) == sorted(word):
        print(line)
f.close()

When I put the same thing onto a Mac, the lines still have a "\" at the end (i.e. "apple\"), and so aren't matching what my input was. Is there something I'm missing?

0

There are 0 answers