Syntax error on the definition of a function in python which seems valid

Viewed 1255

When I define a function in this code:

def is_palindrome(seq):
    s=seq[::-1]
    if s==seq:
         return True
    else:
         return False

myfile=open('palindrome.txt','r')
for line in myfile:
    if is_palindrome(line.srtrip()):
        print(line,end='')
myfile.close()

It returns this error message in my console:

./palindrome.py: line 1: syntax error near unexpected token `('
./palindrome.py: line 1: `def is_palindrome(seq):'

and I don't know what's wrong here.

2 Answers
Related