I have a file that has 50 lines (each line has a name on it) and I would like to take each line and read it, then print it, but in a format that has 5 columns and 10 lines per column.
It would like something like this:
xxxxx -- xxxxx -- xxxxx -- xxxxx -- xxxxx
xxxxx -- xxxxx -- xxxxx -- xxxxx -- xxxxx
xxxxx -- xxxxx -- xxxxx -- xxxxx -- xxxxx
xxxxx -- xxxxx -- xxxxx -- xxxxx -- xxxxx
xxxxx -- xxxxx -- xxxxx -- xxxxx -- xxxxx
This is the code I have so far. It just reads and prints each line on a newline:
f = open('file.txt', 'r')
for x in f:
x = x.lstrip()
x = x.rstrip()
x = x.title()
print x
The reason for the x.lstrip and x.rstip and x.title is because the text is formatted all weird in the file so I have to do that. This is for an assignment. Thanks!