How To Remove "\n" In A List Of Lists (python)
I have a giant list of lists that I imported from a file like this: letters = [] for i in range(len(string)): let = [] for j in range(7): line = infile.readline()
Solution 1:
Wherever your current code has a call to .readline()
, make it .readline().rstrip('\n')
instead.
Solution 2:
Try:
line = infile.readline()
line = line.strip('\n')
let = let + [line]
Post a Comment for "How To Remove "\n" In A List Of Lists (python)"