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.

5
  • It's not an indentation issue. Is there more code before the if statement? Commented Sep 29, 2017 at 9:56
  • Is this the complete code? You should check preceding lines as sometimes the error is due to lines before the reported error line Commented Sep 29, 2017 at 9:57
  • Are you mixing spaces and tabs? Is there some non-printing character at the start of your line? Commented Sep 29, 2017 at 10:01
  • 1
    Running your code give me the error describe here: stackoverflow.com/questions/21639275/… Commented Sep 29, 2017 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. Commented Sep 29, 2017 at 10:11

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.