0

How do I print a line from a text using readline without the [n'] being added

I'm trying to do the workout code-exercise and I've printed the correct line just with unnecessary formating

8th Feb 2021, 6:23 PM
Spencer Selzer
Spencer Selzer - avatar
2 odpowiedzi
+ 5
Iterate each line of the file You can use string.strip() method to remove trailing newlines and whitespaces from the string for line in file.readlines(): line = line.strip() ....
8th Feb 2021, 6:47 PM
noteve
noteve - avatar
+ 1
you could also provide the 'end' argument of print function (with an empty string to override default new line): for line in file.readlines(): print(line,end="")
8th Feb 2021, 9:28 PM
visph
visph - avatar