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
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()
....
+ 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="")