- 1
Why i got spaces between the letters and numbers
file = open("/usercode/files/books.txt", "r") cont=file.readlines() file.close() book_1title=(cont[0]) print(cont[0][0],len(book_1title.strip())) book2_title=(cont[1]) print(cont[1][0],len(book2_title.strip())) book_3title=(cont[2]) print(cont[2][0],len(book_3title.strip())) book_4title=(cont[3]) print(cont[3][0],len(book_4title.strip())) Heres a photo of the output https://www.linkpicture.com/q/Screenshot_20210929-171350.jpg
5 Answers
+ 1
"Image not found"
But when you separate two things in a print statement with a comma python inserts a space. So the output of
print("Image", "not", "found")
is
Image not found
+ 1
You can override this default behaviour with the sep option.
+ 1
There has to be a comma before sep.
https://codescracker.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python-sep.htm
0
Ok i understand now
Thank you very much đ
0
Like this?
book_4title=(cont[3])
print(cont[3][0],len(book_4title.strip()sep=""))