-6
with open('list.txt') as f:
    print " ".join(line.strip() for line in f)

Though the code seems to be correct, but facing syntax error !

2 Answers2

1

In python 3, print is a function. See here: https://docs.python.org/3/whatsnew/3.0.html#print-is-a-function

Try:

with open('list.txt') as f:
    print(" ".join(line.strip() for line in f))
0

You are using python version 3 , Use this

   with open('line.txt') as f:
   print(" ".join(line.strip() for line in f))