0

My code:

print(player_cards[card], end = ", ")

And this is the error message I got:

File "--------", line 97
print(player_cards[card], end = ", ")
                              ^
SyntaxError: invalid syntax

It works perfectly in Pycharm and IDLE, I got this message only when I run it in terminal(Mac)

1
  • 1
    You're either using Python 2 in the terminal, or you have a problem on the previous line. Commented Mar 27, 2016 at 21:31

1 Answer 1

2

When you are in the terminal, do:

python --version

Compare it to the other versions.

I suspect you are running python 2 in the terminal. In that case, run the appropriate python version in the terminal, and it will work just as well.

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

5 Comments

It says "Python 2.7.10", so how do I change it to 3.x?
Have you tried starting it with python -3?
Ok, that makes sense. You need to know where you installed your python 3, and run that binary. Otherwise (better) use a virtual environment manager.
I used "python3" + file path and it works. Thanks :D
Cool, glad it worked :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.