-2

Note: This question is about a problem with repl.it, not a general problem.


Note: You might consider this as a duplicate, but in fact it isn't.
These do not suit my problem:

(Taken from alerady answered questions list, duplicates excluded for compactness)

I've got a problem with for loops in Python (repl.it Python 2 and Python 3 interpreters) in that one-line for loops without a trailing newline raise SyntaxError.

for i in (1,2,3,4,): print i+i+i

Traceback (most recent call last):
  File "python", line 1
    for i in (1,2,3,4,): print i+i+i
                                   ^
SyntaxError: unexpected EOF while parsing
for i in (1,2,3,4,): print i+i+i
# Trailing newline

3
6
9
12

Another question: How to display a trailing newline , trailing space or unprintable character in SE (without using <pre>)?

Community
  • 1
  • 1
EKons
  • 887
  • 2
  • 20
  • 27

1 Answers1

1

It doesn't seem to be a Python problem.

I tried your exact script without a newline on python 2.7 on OS X. It runs successfully. I also tried it on Python 3.5, after adding parens around the argument to print. Still no error.

Looks like a bug specific to repl.it.

alexis
  • 48,685
  • 16
  • 101
  • 161