Python: String Operation
From OnnoCenterWiki
Strip /n
line.strip() will remove all types of whitespaces from both ends of the line. You can use line.rstrip("\n") to remove only the trailing "\n".
Join Line
Pakai str.join:
with open('file.txt') as f:
print " ".join(line.strip() for line in f)