0

I've tried using both Netbeans and PyCharm, but the same error keeps popping up. The error is when I use end="" as instructed by my tutorial it throws different errors depending on what IDE I'm using. Am I completely typing it incorrectly or can someone give me some advice as to what to do

__author__ = "Kevin"
__date__ = "$May 24, 2015 9:23:37 PM$"

print("Pink", end="")
print("Octopus")

The error code in Netbeans is

No viable alternative at input '='

mismatched input '""' expecting RPAREN
----
(Alt-Enter shows hints)
ZdaR
  • 22,343
  • 7
  • 66
  • 87
KevinR
  • 1
  • possible duplicate of [python print end=' '](http://stackoverflow.com/questions/2456148/python-print-end) – kaz May 25 '15 at 02:41

1 Answers1

0

What's most likely happening here is that you are using a Python3 tutorial, but your interpreter in PyCharm and Netbeans is Python2.

In Python2 print was a statement, whereas in Python3 it's a function.

You should be able to fix this by importing the print function in Python2 from the future module:

from __future__ import print_function
print("Pink", end="")  # now works in Python2

Alternativey, you can update PyCharm to use the Python3 interpreter. See here how to set the interpreter.

Martin Konecny
  • 57,827
  • 19
  • 139
  • 159
  • Thank you. I will just update the interpreter to the proper version. I appreciate your time. – KevinR May 25 '15 at 02:38