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 !
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 !
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))
You are using python version 3 , Use this
with open('line.txt') as f:
print(" ".join(line.strip() for line in f))