0

That is my code:

filename = raw_input('Filename? --> ')
‪if filename != 'q':‬
‪    my_socket.send(filename)‬
‪    data = my_socket.recv(1024)‬

when I run - I get this:

  File "temp.py", line 51
‪        if filename != 'q':‬
^
SyntaxError: invalid syntax

I tried over and over to play with the tabs and spaced, but for nothing. It won't work.

Yair Haber
  • 19
  • 2
  • 7
  • It's not an indentation issue. Is there more code before the if statement? – Alan Kavanagh Sep 29 '17 at 09:56
  • Is this the complete code? You should check preceding lines as sometimes the error is due to lines before the reported error line – EdChum Sep 29 '17 at 09:57
  • Are you mixing spaces and tabs? Is there some non-printing character at the start of your line? – VBB Sep 29 '17 at 10:01
  • 1
    Running your code give me the error describe here: https://stackoverflow.com/questions/21639275/python-syntaxerror-non-ascii-character-xe2-in-file – Mel Sep 29 '17 at 10:03
  • you could run find out if the type of 'filename' is 'string' using 'type(filename)', if not, then the comparison operator '!=' will not work. – Benjamin Sep 29 '17 at 10:11

1 Answers1

2

Your code contains a number of unprintable unicode characters. This is why you are getting this error. I found the following characters(U+202A and U+202C) in your code using a non-printable character viewer.

I suggest you type in the code in a plain text editor again.

Unprintable unicode characters

Jayson Chacko
  • 2,388
  • 1
  • 11
  • 16