Reputation: 1
How do I stop each word being printed out on a new line? I have tried stripping new line using word.strip("\n")
Upvotes: 0
Views: 34
Reputation: 177971
print
has an optional parameter to control the line end:
line = 'The quick brown fox jumped over the lazy dog'
for word in line.split():
print(word,end=',')
Output:
The,quick,brown,fox,jumped,over,the,lazy,dog,
Ref: print
Upvotes: 1