0
STRIP()
Guys I'm finding it difficult to understand the strip() method file = open("/usercode/files/books.txt", "r") books = file.readlines() print(books) if this code gets printed, you'd get a list of words with the new line code"/n", but when you print this file = open("/usercode/files/books.txt", "r") books = file.readlines() books = [x.strip() for x in books] print(books) The new line symbol gets deleted somehow. I'm confused cause i thought the strip only works when you specify the characters you want to remove in the parenthesis like this---> strip("\n").
1 Respuesta