0

Here's my code:

for i in range(10):
    print(i, end=' ')  #This line is throwing an error

SyntaxError: no viable alternative at input '='

I am using Netbeans and Jython 2.7.0

Wally
  • 392
  • 4
  • 19
Michael Joshua
  • 47
  • 2
  • 11

1 Answers1

4

You tagged it with python-2.7 and python-3.x, but that shouldn't throw a problem in Python3.

The problem there is that in Python2, print is a statement, so end = ' ' is invalid syntax.

To get the same result, either put from __future__ import print_function at the beginning of the script, or say print i, instead.

zondo
  • 19,040
  • 7
  • 42
  • 82
  • Getting `SyntaxError: no viable alternative at input '='` error even after the import in Jython 2.7.0`. Works in cPython though. – Wally Mar 19 '16 at 04:25